【发布时间】:2011-08-25 17:54:05
【问题描述】:
有人可以帮我把这个 sqlite 查询转换成 postgres 查询吗?
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
更新,我找到了答案:
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
【问题讨论】:
-
您在 potsgres 中使用什么类型的日期列?
-
真的有两个
count(*)还是拼写错误? -
好像有两个
count(*),也不知道为什么。日期类型是“带时区的时间戳”
标签: sql postgresql sqlite