将下面的mysql语句改写为PostgreSQL语句:SELECT LEFT ( jdxz, 9 ) AS street, LEFT ( jdxz, 6 ) AS qx, 'swqc' AS type, COUNT( * ) AS totalnum, ROUND( SUM( IFNULL( jzmj, 0 ) )/ 10000, 2 ) AS totalarea, NOW() AS updatedate FROM swqc_house_base_info WHERE jdxz IS NOT NULL AND deletemark = '0' AND ( yhwt = '1' OR wfjs = '1' OR wfwgsp = '1' ) GROUP BY jdxz
时间: 2024-01-24 16:03:07 浏览: 18
将MySQL数据库移植为PostgreSQL
以下是将该MySQL语句改写为PostgreSQL语句后的结果:
SELECT
LEFT(jdxz, 9) AS street,
LEFT(jdxz, 6) AS qx,
'swqc' AS type,
COUNT(*) AS totalnum,
ROUND(SUM(COALESCE(jzmj, 0))/10000, 2) AS totalarea,
NOW() AS updatedate
FROM
swqc_house_base_info
WHERE
jdxz IS NOT NULL
AND deletemark = '0'
AND (yhwt = '1' OR wfjs = '1' OR wfwgsp = '1')
GROUP BY
jdxz;
需要注意的是,在PostgreSQL中,COALESCE函数被用来代替MySQL中的IFNULL函数。同时,PostgreSQL中使用的当前日期函数为NOW(),而不是MySQL中的CURRENT_DATE()。
阅读全文