sql如下:
select * from (
select sum(a.operate_num) total, c.name as province from (
select * from table1 where ipadress ~ '^((?:(?:25[0-5]|2[0-4]\\\\d|((1\\\\d{2})|([1-9]?\\\\d)))(?:\\\\.)){3}(?:25[0-5]|2[0-4]\\\\d|((1\\\\d{2})|([1-9]?\\\\d))))$'
) a left join table2 c on SUBSTRING(a.area_code,1,4) || '00' = c.code where c.name is not null
and a.app_code = '530900000002' and a.operate_time > '20160410' and a.operate_time <= '20170410235959'
group by province
) tmp
order by tmp.total desc
运行之后就报错了:line 3 ERROR: aggregates not allowed in WHERE clause 说是不允许在WHERE子句中聚集,但是好像并没有吧
数据库是greenplum,有没有了解的,指点下