Mysql group by with different condition

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;

could you please rephrase this?

alternatively, give us a few rows of sample data and then show what result you expect from the query

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.