Hello,
I have below sql running fine on FirebirdSQL but not on PostgreSQL. As I am
not the editor of the SQL, I cannot fix it to work with PostgreSQL. Any help
is appreciated.
Not posting table details not to bloat the message.
I do not have Access to database right now. Error Message I receive is
something like:
Field "kaynak" not found on right table
SELECT RAPOR_EK.KAYNAK, RAPOR_EK.SEBEP, COALESCE(DT.IAIK_OG, 0) AS "IAIK_OG", COALESCE(DT.IAIK_AG, 0) AS "IAIK_AG",
COALESCE(DT.IAIK_TOPLAM,0) AS "IAIK_TOPLAM", COALESCE(DT.IADK_OG, 0) AS "IADK_OG", COALESCE(DT.IADK_AG, 0) AS
"IADK_AG",COALESCE(DT.IADK_TOPLAM, 0) AS "IADK_TOPLAM", COALESCE(DT.GNLTOPLAM, 0) AS "GNLTOPLAM"
FROM RAPOR_EK
LEFT JOIN ( SELECT M.TKS_KAYNAGAGORE AS "KAYNAK", M.TKS_SEBEBEGORE AS "SEBEP",
(sum(M.TES_IMARALANICIOG)/(selectsum(I.ILC_IMARALANICI_OG) from
ILCELER_TABLOSU I where I.ILCEADI = 'CİHANBEYLİ')*60) as "IAIK_OG", (sum(M.TES_IMARALANICIAG)/(select
sum(I.ILC_IMARALANICI_AG)from
ILCELER_TABLOSU I where I.ILCEADI = 'CİHANBEYLİ')*60) as "IAIK_AG", ((sum(M.TES_IMARALANICIOG) +
sum(M.TES_IMARALANICIAG))/ ((select
sum(I.ILC_IMARALANICI_OG) from ILCELER_TABLOSU I where I.ILCEADI =
'CİHANBEYLİ') + (select sum(I.ILC_IMARALANICI_AG) from ILCELER_TABLOSU I
where I.ILCEADI = 'CİHANBEYLİ'))*60) AS "IAIK_TOPLAM", (sum(M.TES_IMARALANDISIOG)/(select sum(I.ILC_IMARALANDISI_OG)
from
ILCELER_TABLOSU I where I.ILCEADI = 'CİHANBEYLİ')*60) as "IADK_OG", (sum(M.TES_IMARALANDISIAG)/(select
sum(I.ILC_IMARALANDISI_AG)from
ILCELER_TABLOSU I where I.ILCEADI = 'CİHANBEYLİ')*60) as "IADK_AG", ((sum(M.TES_IMARALANDISIOG) +
sum(M.TES_IMARALANDISIAG))/ ((select
sum(I.ILC_IMARALANDISI_OG) from ILCELER_TABLOSU I where I.ILCEADI =
'CİHANBEYLİ') + (select sum(I.ILC_IMARALANDISI_AG) from ILCELER_TABLOSU I
where I.ILCEADI = 'CİHANBEYLİ'))*60) AS "IADK_TOPLAM", ((sum(M.TES_IMARALANICIOG) + sum(M.TES_IMARALANICIAG) +
(sum(M.TES_IMARALANDISIOG) + sum(M.TES_IMARALANDISIAG))) / ((select
sum(I.ILC_IMARALANICI_OG) from ILCELER_TABLOSU I where I.ILCEADI =
'CİHANBEYLİ') + (select sum(I.ILC_IMARALANICI_AG) from ILCELER_TABLOSU I
where I.ILCEADI = 'CİHANBEYLİ') + (select sum(I.ILC_IMARALANDISI_OG) from
ILCELER_TABLOSU I where I.ILCEADI = 'CİHANBEYLİ') + (select
sum(I.ILC_IMARALANDISI_AG) from ILCELER_TABLOSU I where I.ILCEADI =
'CİHANBEYLİ'))*60) AS "GNLTOPLAM" FROM TABLO_MEDAS M WHERE M.T_ILCE = 'CİHANBEYLİ' AND M.T_BILDIRIMEGORE =
'Bildirimsiz' AND M.TKS_SUREYEGORE = 'Uzun' AND (M.T_BASLAMATARIHI >= '2015-01-01' AND T_BASLAMATARIHI <=
'2015-01-31 23:59:59') GROUP BY M.TKS_KAYNAGAGORE, M.TKS_SEBEBEGORE
) DT USING (KAYNAK, SEBEP)
ORDER BY KAYNAK, SEBEP
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql