如何将MySQL DATE_FORMAT转换为POstgreSQL?
我有MySQL SQL查询:
SELECT DATE_FORMAT(FROM_UNIXTIME(time_created), '%Y') AS year,
DATE_FORMAT(FROM_UNIXTIME(time_created) , '%m') AS month ,
COUNT(guid) AS total
FROM ossn_users
WHERE(time_created > 0)
GROUP by DATE_FORMAT(FROM_UNIXTIME(time_created) , '%Y%m');
我将其转换为:
SELECT to_char(to_timestamp(time_created), 'YYYY') AS year,
to_char(to_timestamp(time_created) , 'MM') AS month,
COUNT(guid) AS total
FROM ossn_users
WHERE(time_created > 0)
GROUP by to_char(to_timestamp(time_created),'YYYY'), to_char(to_timestamp(time_created),'MM') ;
但它似乎不起作用。
请问,什么是正确的转换?
这次转换是对的吗?
谢谢。