Hi, I have the following crosstab command : Select * from crosstab($$select produkid, warehouseid,onhand
from vwtest order by 1,2$$) as t (produkid VARCHAR, warehouseid integer) vwtest : CREATE OR REPLACE VIEW public.vwtest ( produkid, warehouseid, onhand) AS SELECT dt.produkid, dt.warehouseid, sum(dt.awal + dt.ttlmsk - dt.ttlklr) AS
onhand FROM ( SELECT tblstockawal.kodebarang AS
produkid,
tblstockawal.warehouseid,
sum(tblstockawal.qty) AS awal,
0 AS ttlmsk,
0 AS ttlklr FROM tblstockawal GROUP BY tblstockawal.kodebarang,
tblstockawal.warehouseid UNION SELECT tbltransaksi.kodebarang AS
produkid,
tbltransaksi.warehouseid,
0 AS awal,
sum(tbltransaksi.masuk) AS ttlmsk,
sum(tbltransaksi.keluar) AS ttlklr FROM tbltransaksi GROUP BY tbltransaksi.kodebarang,
tbltransaksi.warehouseid ) dt GROUP BY dt.produkid, dt.warehouseid; The crosstab command didn’t work with error : Return
and sql tuple descriptions are incompatible. I have tried to change productid type to text and
warehouseid to float8 and the problem still not solve. What is wrong with the command ? Thanks |