Jump to content

PHP-MySQL sort/aggregate problem


skulk

Recommended Posts

I want to accomplish the following, either through php or mysql queries, not had much luck in the last few days, so if anyone could help me, ....

I have:

Desc  | +/- | Qty

A        | +  | 10

A        | +  | 10

A        | -  | 20

A        | +  | 5

B        | +  | 2

A        | +  | 3

 

I want the final output to be:

Desc  | +/- | Qty

A        | +  | 8

B        | +  | 2

 

Basically go through the table, and if something has been bought and sold completely, ignore that 'desc'. If not just display the final holding after all +'s and -'s. The first table will be in a mysql table, and the +/- will be 'B'/'S'.

Thanks alot

 

edit .... the 'Desc' is not limited to A and B, it could be as few as 2 variables and as many as 300.

Link to comment
https://forums.phpfreaks.com/topic/62262-php-mysql-sortaggregate-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.