Skip to content
Advertisement

SQL Query Count With JOIN

I’ve the following SQL Query which runs perfectly fine but now i want to calculate the count based on the following scenario:

The current Output is:

Text

Now i want to show the count like this way:

High (Open) – 2

High (Closed) – 0

Medium (Open) – 1

Medium (Closed) – 0

Low (Open) – 3

Low (Closed) – 1

Please help me to solve this query, Thank You

Advertisement

Answer

You need to CROSS JOIN the distinct sets of severity and status values and then LEFT JOIN that to your table to allow you to count the values of each severity/status combination. Without sample data it’s hard to be certain but something like this should work:

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