79462487

Date: 2025-02-24 05:05:23
Score: 3.5
Natty:
Report link
SELECT  * FROM (SELECT jk.lingkungan_id,SUM(CASE WHEN j.sidi_id=1 AND j.jk=1  THEN 1 ELSE 0 END)L,SUM(CASE WHEN j.sidi_id=1 AND j.jk=2  THEN 1 ELSE 0 END)P,SUM(CASE WHEN j.sidi_id=1  THEN 1 ELSE 0 END)JLH FROM jemaat j JOIN jemaat_kel jk ON (jk.nokk = j.nokk) GROUP BY jk.lingkungan_id UNION ALL SELECT pmk.lingkungan_id,
     SUM(CASE WHEN pmk.jk=1  THEN 1 ELSE 0 END)L,
     SUM(CASE WHEN pmk.jk=2  THEN 1 ELSE 0 END)P,
     SUM(CASE WHEN pmk.jk IN(1,2)  THEN 1 ELSE 0 END)JLH
     FROM tbl_pmk pmk
      JOIN jemaat j
      ON (pmk.jemaat_id = j.jemaat_id)
      GROUP BY pmk.lingkungan_id ) AS combined GROUP BY lingkungan_id ORDER BY lingkungan_id;

After I tried the script above, the result only got 4 columns like this enter image description here how to display the 2nd query ?

Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Franky Moedak