Skip to content
Advertisement

How can I write this SQL query [closed]

I have a database table looks like this:

I want to write a SQL query or something like that or a reporting tool to generate a report as below:

I tried different ways but still not sure how to do that? Anyone can help?

Advertisement

Answer

You can use conditional aggregation:

Note that group is a really bad name for a column, because it is a SQL keyword. If this is the actual name, I would suggest you change it.

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