1
我的Postgres的交叉表查詢寫着:PostgreSQL的交叉表查詢從一個輔助查詢拉動列
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
替換最後一行,但這不起作用。
你有答案嗎? –