Asked
Viewed 253 times
SELECT DATE(A.Inspection_datetime) AS Date,
A.Model,
COUNT(A.Serial_number) AS Qty,
B.Name
FROM inspection_report AS A
LEFT JOIN Employee AS B ON A.NIK = B.NIK
GROUP BY A.Model, A.Serial_number
14.5k7 gold badges58 silver badges65 bronze badges
5
1 Answer 1
At a guess (and believe me, I'm guessing)
SELECT DATE(A.Inspection_datetime) AS Date,
A.Model,
COUNT(A.Serial_number) AS Qty,
B.Name
FROM inspection_report AS A
LEFT JOIN Employee AS B ON A.NIK = B.NIK
GROUP BY A.Model, B.Name
You need to group by the fields you're not aggregating
Sign up to request clarification or add additional context in comments.
lang-sql

A question usually requires a question ;-)
2010-08-23 09:28:55 +00:00
Commented Aug 23, 2010 at 9:28
Change to do what? Or is there something wrong with it? You might need more columns on the
GROUP BYto match the list you're returning (e.g.DATE(A.Inspection_datetime)), and it'd make more sense toCOUNT()on a column in table B rather than the column you're grouping on (e.g. B.NIK) though that might not actually be a problem.2010-08-23 09:29:23 +00:00
Commented Aug 23, 2010 at 9:29
Click on the parts of the code you want changed with your mouse which will probably be located somewhere near your computer. You will need to then press the corresponding keys on your character entry device to apply the changes in the code. Feel free to use both hands, you don't need to keep hold of the mouse when you are happy with the pointers position on your monitor.
2010-08-23 09:30:50 +00:00
Commented Aug 23, 2010 at 9:30
Finally a question that really deserves the "not a real question" closing.
2010-08-23 09:31:17 +00:00
Commented Aug 23, 2010 at 9:31
Some sample data and expected results would be nice too.
2010-08-23 09:34:14 +00:00
Commented Aug 23, 2010 at 9:34