Can someone help me convert this sqlite query to a postgres query?
SELECT count(*), count(*), date(date, '-'||strftime('%w',date)||' days') as date
FROM emails as m, contacts as me
WHERE datetime(date) > datetime('2010-08-25')
and datetime(date) < datetime('2011-08-25')
and (me.id = m.fr)
and me.email like '%gmail.com%'
GROUP BY date
ORDER BY date asc
update, I found the answer:
select count(*), (m.date::date - extract(dow from m.date)::int) as dat
from emails as m join contacts as me on m.fr = me.id
where m.date > '2010-08-25'
and m.date < '2011-08-25'
and me.email like '%gmail.com%'
group by dat
order by dat
count(*)or is that a typo?count(*), not sure why either. the date type is "timestamp with timezone"