7 ms·
Most of the time I'm using `filter ... where` for cases like these... for example select column_name, MAX(value) FILTER (where meta_key='total_rows')
by jasonpbecker 2y ago
Most of the time I'm using `filter ... where` for cases like these... for example
select
column_name,
MAX(value) FILTER (where meta_key='total_rows') as total_row,
MAX(value) FILTER (where meta_key='not_null_count') as not_null_count,
ROUND(SUM (amount_in_cents) FILTER (WHERE EXTRACT(MONTH FROM TIMESTAMP '2006-01-01 03:04:05) = 1) / 100.0, 2) as 'january_sub_total'
FROM table
GROUP BY column_name
- kanobi 2y agoYup, that's even better. I think it didn't work for me because I was using Redshift, which didn't support FILTER at that time.