Posted by Rik on 05/07/06 12:33
Alex Murphy wrote:
> Hi all,
>
> I using the "list" function to extract the sales text delimited file
> and insert into the table. How to find out the best sales item and
> worst sales item?
Summing is easy:
SELECT `item`, SUM(`qty`) AS 'total_sold' FROM table_name GROUP BY `item`
Extracting best and worst in one query in one go is a little bit trickier.
I'm sure it's possible in one query, but I'm not familiar enough with JOINS
or subqueries to figure that one out.
That's more of a database question, which database are you using?
Grtz,
--
Rik Wasmus
[Back to original message]
|