Постгресс, когда
SUM(CASE WHEN column = value THEN column END) alias
eg
SUM(CASE WHEN car.brand = 'Toyota' THEN sales END) toyota_sales
Benedict Ouma
SUM(CASE WHEN column = value THEN column END) alias
eg
SUM(CASE WHEN car.brand = 'Toyota' THEN sales END) toyota_sales