I'm having a hard time putting some queries together.
SELECT `part_num`, COUNT(`part_num`) AS `total`
FROM `job_sheet`
WHERE `qty`!=0 AND `completion`=1
GROUP BY `part_num`
ORDER BY `total` DESC
LIMIT 10
This basically pulls up the most common part number and it shows how many times it appears in the 'total' variable. I also limited to the top 10 part number in this case. These parts number also have a quantity column 'qty' that shows how many parts there are:
part_num | qty
1001 | 1000
1004 | 200
1003 | 360
1001 | 1000
1001 | 1000
In this case my first statement would show that part number 1001 would appear three times, item number 4 would appear once etc., etc. My issue is that I would like to add up the qty column along with my statement in order to show that item 1001 appears 3 times with a 'qty' sum of 3000.
Any ideas on how to do this ?