sql >> データベース >  >> RDS >> Mysql

SQLクエリの結果を特定の形式のHTMLテーブルに変換する方法

    これを試してください:

    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. MariaDBでのFORMAT()のしくみ

    2. データベースのコンマリストで特定の値を検索します

    3. MySQLテーブルの欠落している値を補間します

    4. MariaDBバージョンを確認する6つの方法