Skip to content
Advertisement

get the count of unread messages

I have this requirement with our DB like shown below

I want to get the 3 columns requestType, CategoryGroup, and count of readStatus column

The result will show all the requestType along with categoryGroup and with if readStatus is false then it will show the count of it and if all readStatus is true in that same requestType then return 0.

also if requestType is NULL and Blank in same categoryGroup (from table A, subcategoryId 12 and 13 are from same categoryGroup in table B), then the categoryGroup should shown as BLANK and should hold the count of (readStatus=0) both NULL and BLANK

Result count

The query which I have written is returning only the columns and count in respect to readStatus=false and showing the total count of it.

Expected result for above query is :

enter image description here

Advertisement

Answer

I would do something like:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement