I want to join two tables counting and grouping the elements in the table A based on the element in the table B. This table can have duplicates (A):
This one is reference table for the output (B):
and I would like to obtain an output like this:
so the output has the same number of rows of the B table but counting the one in A.
I tried to do something like that without success:
SELECT B.id, B.Serial, B.Type, COUNT(A.id)
FROM B
LEFT JOIN A ON A.id = B.id
WHERE B.id = 100
GROUP BY B.Serial, B.Type
someone can help me?