i have following small mysql table with 4 fields as id, subtype , rate and amount. I have to execute querry in a way that when id is same and subtype is between (11 and 12) then it should sum rate and amount column. This working fine untill this point but I in ELse section I want it should show table rows as it were added in database.
SELECT id, SUM(CASE WHEN subtype in (11, 12) THEN rate [ELSE 0] END) ... GROUP BY id;