sql >> Database >  >> RDS >> Mysql

Hoe de resultaten van een sql-query te transformeren naar een html-tabel met een specifiek formaat

Probeer dit:

SELECT A.month, 
       SUM(CASE WHEN A.department = 'Physics' AND A.property = 'undergraduate' THEN A.total_no_students ELSE 0 END) AS Physics_undergraduate, 
       SUM(CASE WHEN A.department = 'Physics' AND A.property = 'postgraduate' THEN A.total_no_students ELSE 0 END) AS Physics_postgraduate, 
       SUM(CASE WHEN A.department = 'Architecture' AND A.property = 'undergraduate' THEN A.total_no_students ELSE 0 END) AS Architecture_undergraduate, 
       SUM(CASE WHEN A.department = 'Architecture' AND A.property = 'postgraduate' THEN A.total_no_students ELSE 0 END) AS Architecture_postgraduate, 
       SUM(CASE WHEN A.department = 'Biology' AND A.property = 'undergraduate' THEN A.total_no_students ELSE 0 END) AS Biology_undergraduate, 
       SUM(CASE WHEN A.department = 'Biology' AND A.property = 'postgraduate' THEN A.total_no_students ELSE 0 END) AS Biology_postgraduate
FROM (...Your Existing Query...) AS A 
GROUP BY A.month



  1. Sailsjs Mysql ORM meerdere zoekopdrachten op hetzelfde tabelveld

  2. pg -v 0.17.1 installeren

  3. SQLSTATE [HY093]:Ongeldig parameternummer:parameter is niet gedefinieerd

  4. MVC4:UserIsInRole - Kan geen verbinding maken met SQL Server-database