I have the following query
Select count(*) as TotalCount from ABC where ID in (1,3,6)
The problem here is that it gives me the total count of 1,3 and 6. But I would like to get the count for each ID, something like shown below:
TotalCount, ID
6, 1
2, 3
5, 6
Kindly let me know the SQL Server query for achieving this. I wouldn’t prefer to use Temp tables.
simply add the id to the selected columns and group by them: