Skip to content
Advertisement

SQL query for report by name with many columns count by status

Is it possible by sql query to produce a report group by a name with count by status.

Tables:

  • Project (id, name, status_id, service_id)
  • Status (id, name)
  • Service (id, name)

I need to make a report, count by status group by service:

Columns results: Service name, status name 1 , status name 2, status name 3, total

Rows results:

Advertisement

Answer

You seem to want joins and conditional aggregation:

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