将sqlite查询转换为postgres
我有来自sqlite的以下查询,并希望将其转换为postgres:将sqlite查询转换为postgres,sqlite,postgresql,Sqlite,Postgresql,我有来自sqlite的以下查询,并希望将其转换为postgres: select date(date, '-'||strftime('%w', date)||' days') as date from msgs group by date order by date asc limit 10; 更新: 我相信这可以做到:选择date::date-extractdow from date::int::date as d from msgs group by d order by d asc li
select date(date, '-'||strftime('%w', date)||' days') as date from msgs group by date order by date asc limit 10;
更新:
我相信这可以做到:选择date::date-extractdow from date::int::date as d from msgs group by d order by d asc limit 10 那要看情况而定。是否更重要的是按日期分组,然后将输出更改为所需的格式?或者您最好按datedate、“-”| | strftime“%w”、date、| | days”进行分组?如果你只想按日期分组,那么做一些类似的事情 选择datex.date'-'| | strftime'%w',x.date | | |'days',从msgs group by date order by date by date asc limit 10中选择日期作为x
否则,按datedate、“-”| | strftime“%w”、date、| |天进行分组,您就完成了。需要转换哪些部分?您是否尝试在Postgre中使用它,或者检查是否使用了任何不兼容的部分?需要转换整个语句。对于不熟悉SQLite函数的人:表达式datedate、“-”|| strftime“%w”,date | | days的计算结果为日期当天或之前的最后一个星期日。