我的 Postgres 交叉表查询内容如下:
SELECT mthreport.*
FROM crosstab
('SELECT
to_char(ipstimestamp, ''mon DD HH24h'') As row_name,
varid::text || log.varid || ''_'' || ips.objectname::text As bucket,
COUNT(*)::integer As bucketvalue
FROM loggingdb_ips_boolean As log
INNER JOIN IpsObjects As ips
ON log.Varid=ips.ObjectId
GROUP BY to_char(ipstimestamp, ''yyyy MM DD HH24h''), row_name, bucket
ORDER BY to_char(ipstimestamp, ''yyyy MM DD HH24h''), row_name, bucket')
As mthreport(item_name text,
jan3 integer, feb4 integer, mar5 integer)
有什么方法可以jan3 integer
从辅助查询中提取最后一行(等)中列举的三个项目?我试图用 替换最后一行SELECT xyz FROM zyx
,但这不起作用。