I have a table like-
id---------rowNum------status
aa23 1 HIT
aa23 1 HIT
aa23 1 HIT
aa23 2 MISS
aa23 2 MISS
aa24 2 MISS
aa24 2 MISS
So basically I need to get the count of and HIT and MISS given the ID
For example-
if I am given aa23 I should return
status-----count
HIT 1
MISS 1
The rowNums should be distinct so given id=aa23 the HIT occurs thrice but all are rowNum 1 so should be counted once same for Miss
2
Answers
You can do it using
group by
as follows :Demo here
you could elemente all duplicates first and also only select the id you want and the count the resulting rows
fiddle