select * from tblA a
left join tblB b on b.id = a.bId
group by a.bId
If I group based on a column, I get only the first record of the records that have same
bID
value. Is there a way to also get the total number of records that have same bId
, for each row? Without doing a separate query...
id | bId
--------
1 | 1
2 | 1
3 | 1
4 | 2
5 | 3
so in the above query I would expect
id | bId. | counts
-------------------
1 | 1 | 3 <- 3 records with bId = 1
4 | 2 | 1
5 | 3 | 1
Asked by Alex
(181 rep)
Mar 24, 2025, 01:29 PM
Last activity: Mar 24, 2025, 03:08 PM
Last activity: Mar 24, 2025, 03:08 PM