Group by SQL with count -
We say we have rows:
MyTable
ID Name Products ------------------ 1 Adam X2 Adam Y3 Adam J4 Peter A5 Peter B.
query Use: eg name, calculation (product) from the Meritable group by name:
will be the result:
< Code> Adam 3 Peter 2
But I would like the result like:
1 Adam x 3 2 Adam y 3 3 Adam J3 4 Peter A2 5 Peter B2
I hope that Ypu knows what I mean, can you help me with that question, thanks for the help, bye
You can join the table with a subdirectory run on the table to select the numbers:
SELECT a.ID as the id, as the name Name. , a. The product as a product, from ISUNLL (BCCT, 0) Mitebab, a left zone (SELECT Name, COUNT (*) as CNT by name as MyTable GROUP BY) b on.Name = b.Name < / Code>
Comments
Post a Comment