V
Visitor
I've got a query that I just can't seem to get right.
I have a table (orders) with itemName and itemQty. Every order makes a
new row so I can have many rows with the same itemName plus the
itemQty that was ordered.
What i'm trying to do is get how the total number of each item
ordered.
First try:
SELECT itemName, count(*) as popitemCount
FROM Orders
Group By itemName
ORDER BY Count(*) DESC
Looks good except it only tells me how many times each item was
ordered regardless of itemQty, not how many total of each item.
I need something like..
SELECT itemName * itemQty, count(*) as popitemCount
FROM Orders
Group By itemName
ORDER BY Count(*) DESC
-Of course the above does not work but you get the idea.
This seems so simple, what am i missing? Any suggestions would be
appreciated greatly.
-Johnny B
I have a table (orders) with itemName and itemQty. Every order makes a
new row so I can have many rows with the same itemName plus the
itemQty that was ordered.
What i'm trying to do is get how the total number of each item
ordered.
First try:
SELECT itemName, count(*) as popitemCount
FROM Orders
Group By itemName
ORDER BY Count(*) DESC
Looks good except it only tells me how many times each item was
ordered regardless of itemQty, not how many total of each item.
I need something like..
SELECT itemName * itemQty, count(*) as popitemCount
FROM Orders
Group By itemName
ORDER BY Count(*) DESC
-Of course the above does not work but you get the idea.
This seems so simple, what am i missing? Any suggestions would be
appreciated greatly.
-Johnny B