Forum
Bildirimler
Hepsini Temizle
ERP MRP Yazılım Programları
2
Yazılar
2
Üyeler
0
Reactions
520
Görüntüleme
Konu başlatıcı
Sadece bir müşteride meydana gelen bir problem var müşterinin ekstresine girdğim anda karşıma böyle bir hata mesajı veriyor sizce ne yapmam lazım ?
512 - [Microsoft][ODBC SQL Server Driver][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
SQL : SELECT tbMusteri.lKodu as lKodu,
tbMusteri.sAdi+ ' ' + tbMusteri.sSoyadi as sMusteriAdi,
dtefaturaTarihi as dteTarih,
tbAlisVeris.sFisTipi as fisTipi,
lFaturaNo as lNo,
tbStok.sKodu as sKodu,
rtrim(tbStok.sAciklama) + rtrim((case when tbStok.sRenk = '' then '' else ' - ' + substring(sRenkAdi,1,15) end)) as sStokAciklama,
isnull(tbStokFisiDetayi.lCikisMiktar1, 0) as Miktar,
isnull(tbStokFisiDetayi.lBrutFiyat,0) as Fiyat,
isnull(lIskontoTutari,0) as Iskonto,
lNetTutar= case when dtefisTarihi is null then tbAlisveris.lnetTutar+lvadefarki else isnull(tbStokFisiDetayi.lBrutTutar - lIskontoTutari,0) +lvadefarki end ,
tbAlisveris.lnetTutar+lvadefarki as OdemeTutar ,
(case when tbStokFisiDetayi.nGirisCikis = 4 then sStokIslem else '' end) as OdemeTipi,
tbStokFisiDetayi.sSaticiRumuzu as SaticiRumuzu,
tbAlisVeris.sKasiyerRumuzu as KasiyerRumuzu,
'' as Teslimatci ,
sAlisverisYapanAdi + ' ' + sAlisverisYapanSoyadi as AlisverisiYapan,
tbAlisVeris.nAlisVerisId as Id,
'01/01/2078' as TaksitTarihi,
case when isnull(bSenetTeslimEdildi,0) = 1 then 3 else 0 end as TaksitTutari,
tbAlisVeris.sFisTipi + '-' + tbAlisveris.sMagaza + ' ' + TBdEPO.sAciklama as OdemeAciklama ,
0 as Tipi
,tbAlisVeris.nGirisCikis as GirisCikis ,IadeAvInf = case when tbAlisVeris.nGirisCikis <>4 or tbAlisveris.sFisTipi not in ('K', 'SK') then '' else isnull((select Distinct convert(char(10),IadeAlisVeris.dteFaturaTarihi,103) + '-' + ltrim(str(IadeAlisVeris.lFaturaNo)) from tbOdeme as Odeme,tbAlisveris IadeAlisVeris where tbAlisveris.nAlisverisId = Odeme.nAlisverisId and Odeme.nIadeAlisverisId = IadeAlisVeris.nAlisVerisId),'') end ,lMalBedeli =case tbAlisVeris.sFisTipi when 'KVF' then 0 else lMalBedeli end
,'' as sHareketTipi
,tbStokFisidetayi.nIslemId, case when tbAlisveris.sFisTipi in ( 'P','PD','PTX','SP') then '' else ( case when tbStokFisidetayi.sOdemeKodu = '' then tbAlisveris.sOdemeKodu else tbStokFisidetayi.sOdemeKodu end) end as StokOdeme
,'' as SevkAciklama
,0 as KalanTaksit
,convert(char(10),tbAlisVeris.dteKayitTarihi, 103) + '-' + convert(char(5),tbAlisVeris.dteKayitTarihi, 108) as KayitTarihi, tbStokFisiDetayi.sFiyatTipi
,tbStokFisiDetayi.nIskontoYuzdesi , tbAlisVeris.nDipIskontoYuzdesi
From tbdepo,tbMusteri ,tbFisTipi, tbAlisVeris
left outer Join tbStokFisiDetayi on tbstokFisiDetayi.nAlisverisID = tbAlisveris.nAlisverisID
left Outer Join (select tbStok.*, tbRenk.sRenkAdi from tbStok, tbRenk where tbstok.sRenk = tbRenk.sRenk ) as tbstok
on tbStok.nStokID=tbStokFisiDetayi.nStokID
left Outer Join tbAVSenetTeslim
on tbAVSenetTeslim.nAlisverisID=tbAlisveris.nAlisverisID
where tbdepo.sDepo=tbAlisVeris.sMagaza and
tbAlisVeris.nMusteriID=tbMusteri.nMusteriID and
dteFaturaTarihi between '01/01/1900' and '31/12/2078' and
( tbAlisVeris.sFisTipi='P' or tbAlisVeris.sFisTipi='K' or tbAlisVeris.sFisTipi='Ks' OR tbAlisVeris.sFisTipi='PD' OR tbAlisVeris.sFisTipi='PTX') and
tbALisveris.sFisTipi = tbFisTipi.sFisTipi and
lKodu =8060242
Union All
SELECT tbMusteri.lKodu as lKodu,
tbMusteri.sAdi+ ' ' + tbMusteri.sSoyadi as sMusteriAdi,
dtefaturaTarihi as dteTarih,
tbAlisVeris.sFisTipi as fisTipi,
lFaturaNo as lNo,
tbStok.sKodu as sKodu,
rtrim(tbStok.sAciklama) + rtrim((case when tbStok.sRenk = '' then '' else ' - ' + substring(sRenkAdi,1,15) end)) as sStokAciklama,
isnull(tbalisverisSiparis.lGCMiktar, 0) as Miktar,
isnull(tbalisverisSiparis.lBrutFiyat,0) as Fiyat,
isnull(tbalisverisSiparis.lIskontoTutari,0) as Iskonto,
lNetTutar= case when dtefaturaTarihi is null then tbAlisveris.lnetTutar+lvadefarki else isnull(tbalisverisSiparis.lBrutTutar - tbalisverisSiparis.lIskontoTutari,0) +lvadefarki end ,
tbAlisveris.lnetTutar+lvadefarki as OdemeTutar ,
tbAlisverisSiparis.sIadeNedeni as OdemeTipi,
rtrim(tbalisverisSiparis.sSaticiRumuzu) + (case when rtrim(tbalisverisSiparis.sSaticiRumuzu) <> '' then ' - ' else '' end) + (case bTeslimEdildi when 0 then convert(char(10),dteTeslimEdilecek,103) else convert(char(10),dteTeslimEdilen,103) end)
+ ' - ' + isnull(( select distinct lTrim(rtrim(tbDepo.sDepo)) + '/' + ltrim(rtrim(tbDepo.sAciklama)) from tbDepo , tbStokFisiDetayi TRANS , tbStokFisiDetayi FAT
where tbDepo.sDepo = TRANS.sDepo and TRANS.sFisTipi = 'T' and
TRANS.nGirisCikis = 3 and TRANS.sHangiUygulama = 'PI' and
TRANS.dteFisTarihi = FAT.dteIrsaliyeTarihi and TRANS.lFisno = FAT.lFisno and TRANS.sTransferDepo = FAT.sDepo and
FAT.nIslemID = tbAlisverisSiparis.nStokIslemID and TRANS.nStokID = FAT.nStokID) , '') as SaticiRumuzu,
tbAlisVeris.sKasiyerRumuzu as KasiyerRumuzu,
'' as Teslimatci ,
sAlisverisYapanAdi + ' ' + sAlisverisYapanSoyadi as AlisverisiYapan,
tbAlisVeris.nAlisVerisId as Id,
'01/01/2078' as TaksitTarihi,
case when isnull(bSenetTeslimEdildi,0) = 1 then 3 else (case bTeslimEdildi when 1 then (bTeslimEdildi * (case bEkalan2 when '' then 1 else 0 end)) else (case when dteOnayTarihi = '01/01/1900' then 0 else 2 end) end) end as TaksitTutari,
tbAlisVeris.sFisTipi + '-' + tbAlisveris.sMagaza + ' ' + TBdEPO.sAciklama as OdemeAciklama ,
0 as Tipi
,tbAlisVeris.nGirisCikis as GirisCikis ,IadeAvInf = case when tbAlisVeris.nGirisCikis <>4 or tbAlisveris.sFisTipi not in ('K', 'SK') then '' else isnull((select Distinct convert(char(10),IadeAlisVeris.dteFaturaTarihi,103) + '-' + ltrim(str(IadeAlisVeris.lFaturaNo)) from tbOdeme as Odeme,tbAlisveris IadeAlisVeris where tbAlisveris.nAlisverisId = Odeme.nAlisverisId and Odeme.nIadeAlisverisId = IadeAlisVeris.nAlisVerisId),'') end ,lMalBedeli =case tbAlisVeris.sFisTipi when 'KVF' then 0 else lMalBedeli end
,'' as sHareketTipi
,0 as nIslemID , case when tbAlisveris.sFisTipi in ( 'P','PD','PTX','SP') then '' else (case when tbAlisverisSiparis.sOdemeKodu = '' then tbAlisveris.sOdemeKodu else tbAlisverisSiparis.sOdemeKodu end) end as StokOdeme
,'' as SevkAciklama
,0 as KalanTaksit
,convert(char(10),tbAlisVeris.dteKayitTarihi, 103) + '-' + convert(char(5),tbAlisVeris.dteKayitTarihi, 108) as KayitTarihi, tbAlisverisSiparis.sFiyatTipi
,tbAlisverisSiparis.nIskontoYuzdesi , tbAlisVeris.nDipIskontoYuzdesi
From tbdepo,tbMusteri ,tbFisTipi, tbAlisVeris
left outer Join tbalisverisSiparis on
tbalisverisSiparis.nAlisverisID=tbAlisVeris.nAlisverisID
left Outer Join (select tbStok.*, tbRenk.sRenkAdi from tbStok, tbRenk where tbstok.sRenk = tbRenk.sRenk ) as tbstok
on tbStok.nStokID=tbalisverisSiparis.nStokID
left Outer Join tbStokFisiDetayi
on tbalisverisSiparis.nStokIslemID=tbStokFisiDetayi.nIslemID
left Outer Join tbAVSenetTeslim
on tbAVSenetTeslim.nAlisverisID=tbalisveris.nAlisverisID
where tbdepo.sDepo=tbAlisVeris.sMagaza and
tbAlisVeris.nMusteriID=tbMusteri.nMusteriID and
dteFaturaTarihi between '01/01/1900' and '31/12/2078' and
( tbAlisVeris.sFisTipi='SP' or tbAlisVeris.sFisTipi='SK') and
tbALisveris.sFisTipi = tbFisTipi.sFisTipi and
lKodu =8060242
Union All
SELECT tbMusteri.lKodu as lKodu,
tbMusteri.sAdi+ ' ' + tbMusteri.sSoyadi as sMusteriAdi,
dteFaturaTarihi as dteTarih,
tbAlisVeris.sFisTipi as fisTipi,
lFaturaNo as lNo,
'' as sKodu,
'' as sStokAciklama,
0 as Miktar,
0 as Fiyat,
0 as Iskonto,
lNetTutar = case when tbAlisVeris.sFistipi='Pad' then lNetTutar else lVadeFarki end,
0 as OdemeTutar ,
'' as OdemeTipi,
'' as SaticiRumuzu,
sKasiyerRumuzu as KasiyerRumuzu,
'' as Teslimatci ,
sAlisverisYapanAdi + ' ' + sAlisverisYapanSoyadi as AlisverisiYapan,
tbAlisVeris.nAlisVerisId as Id,
'01/01/2078' as TaksitTarihi,
0 as TaksitTutari,
tbAlisVeris.sFisTipi as OdemeAciklama ,
1 as Tipi
,tbAlisVeris.nGirisCikis as nGirisCikis,'' IadeAvInf ,0 as lMalBedeli
,'' as sHareketTipi
,0 nIslemId , '' as StokOdeme
,'' as SevkAciklama
,0 as KalanTaksit
,ltrim(rtrim(tbAlisVeris.sMagaza)) + ' - ' + tbDepo.sAciklama as KayitTarihi, '' as sFiyatTipi
,0 nIskontoYuzdesi , 0 nDipIskontoYuzdesi
From tbFisTipi, tbAlisVeris, tbMusteri, tbDEpo
where tbAlisVeris.nMusteriID=tbMusteri.nMusteriID and
tbAlisveris.sMagaza = tbDepo.sDepo and
dteFaturaTarihi between '01/01/1900' and '31/12/2078' and
( tbAlisVeris.sFisTipi='PAD' or tbAlisVeris.sFisTipi='KVF' OR tbAlisVeris.sFisTipi='PD' OR tbAlisVeris.sFisTipi='PTX') and
tbALisveris.sFisTipi = tbFisTipi.sFisTipi and
lKodu = 8060242
Union All
SELECT lKodu, sMusteriAdi, dteTarih, fisTipi, lNo, sKodu, sStokAciklama, Miktar,
Fiyat, Iskonto, lNetTutar, sum(OdemeTutar) , OdemeTipi, SaticiRumuzu, KasiyerRumuzu,
Teslimatci , AlisverisiYapan, Id, TaksitTarihi, Sum(TaksitTutari), OdemeAciklama, Tipi
,GirisCikis,''IadeAvInf ,0 as lMalBedeli
,'' as sHareketTipi
,0 nIslemId, '' as StokOdeme
,'' as SevkAciklama
,0 as KalanTaksit
,KayitTarihi, '' as sFiyatTipi
,0 nIskontoYuzdesi , 0 nDipIskontoYuzdesi
from (
Select tbMusteri.lKodu as lKodu,
tbMusteri.sAdi+ ' ' + tbMusteri.sSoyadi as sMusteriAdi,
dteOdemeTarihi as dteTarih ,
FisTipi = case when nOdemekodu<>1 then 'Z' else tbAlisVeris.sFisTipi end ,
lNo = case when nOdemekodu<>1 then 0 else tbalisveris.lFaturaNo end,
'' as sKodu ,
'' as sStokAciklama,
0 as Miktar,
0 as Fiyat,
0 as Iskonto,
0 as lNetTutar,
lOdemeTutar as OdemeTutar ,
tbOdeme.sOdemeSekli as OdemeTipi,
'' as SaticiRumuzu,
tbOdeme.sKasiyerRumuzu as KasiyerRumuzu,
'' as Teslimatci ,
'' as AlisverisiYapan,
Id = case when nOdemekodu<>1 then '0' else tbOdeme.nAlisVerisId end,
'01/01/2078' as TaksitTarihi,
cast(nOdemeKodu as int) as TaksitTutari,
convert(char(10) ,dteOdemeTarihi,103) as OdemeAciklama ,
2 as Tipi
,tbAlisVeris.nGirisCikis as GirisCikis
,'' IadeAvInf ,0 as lMalBedeli
,'' as sHareketTipi
,0 nIslemId , '' as StokOdeme
,'' as SevkAciklama
,0 as KalanTaksit
,ltrim(rtrim(tbOdeme.sMagaza)) + ' - ' + tbDepo.sAciklama as KayitTarihi, '' as sFiyatTipi
,0 nIskontoYuzdesi , 0 nDipIskontoYuzdesi
From tbDepo, tbFisTipi, tbAlisVeris, tbMusteri, tbOdeme with(index = tbOdeme_index4),tbOdemeSekli
where tbOdeme.sOdemeSekli = tbOdemeSekli.sOdemeSekli and TbOdeme.nAlisverisId= TbAlisveris.nAlisverisId and
tbOdeme.sMagaza = tbDEpo.sDepo and
tbAlisVeris.nMusteriID=tbMusteri.nMusteriID and
(nOdemeKodu<3) and
dteOdemeTarihi between '01/01/1900' and '31/12/2078' and
( tbAlisVeris.sFisTipi='P' or tbAlisVeris.sFisTipi='K' or tbAlisVeris.sFisTipi='PAD' or tbAlisVeris.sFisTipi='KVF' or tbAlisVeris.sFisTipi='Ks' OR tbAlisVeris.sFisTipi='PD' OR tbAlisVeris.sFisTipi='PTX' or tbAlisVeris.sFisTipi='SP' or tbAlisVeris.sFisTipi='SK') and
tbALisveris.sFisTipi = tbFisTipi.sFisTipi and
lKodu = 8060242
) as a group by GirisCikis,lKodu, sMusteriAdi, dteTarih, fisTipi, lNo, sKodu, sStokAciklama, Miktar,
Fiyat, Iskonto, lNetTutar, OdemeTipi, SaticiRumuzu, KasiyerRumuzu,
Teslimatci , AlisverisiYapan, Id, TaksitTarihi, OdemeAciklama, Tipi, KayitTarihi
Union All
SELECT lKodu, sMusteriAdi, dteTarih, fisTipi, lNo, sKodu, sStokAciklama, Miktar,
Fiyat, Iskonto, lNetTutar, OdemeTutar , OdemeTipi, SaticiRumuzu, KasiyerRumuzu,
Teslimatci , AlisverisiYapan, '0' Id, TaksitTarihi, Sum(TaksitTutari), OdemeAciklama, Tipi
,5 as GirisCikis,'' IadeAvInf ,0 as lMalBedeli
,'' as sHareketTipi
,0 nIslemId , '' as StokOdeme
,'' as SevkAciklama
,0 as KalanTaksit
,'' as KayitTarihi, '' as sFiyatTipi
,0 nIskontoYuzdesi , 0 nDipIskontoYuzdesi
from (
SELECT tbMusteri.lKodu as lKodu,
tbMusteri.sAdi+ ' ' + tbMusteri.sSoyadi as sMusteriAdi,
'31/12/2078' as dteTarih,
'' as fisTipi,
0 as lNo,
'' as sKodu,
'' as sStokAciklama,
0 as Miktar,
0 as Fiyat,
0 as Iskonto,
0 as lNetTutar,
0 as OdemeTutar ,
'' as OdemeTipi,
'' as SaticiRumuzu,
'' as KasiyerRumuzu,
'' as Teslimatci ,
'' as AlisverisiYapan,
tbTaksit.nTaksitId as Id,
dteTarihi as TaksitTarihi,
lTutari -sum(Isnull(lOdemeTutar,0)) as TaksitTutari,
'' as OdemeAciklama ,
3 as Tipi
,5 as GirisCikis,'' IadeAvInf ,0 as lMalBedeli
,'' as sHareketTipi
,0 nIslemId , '' as StokOdeme
,'' as SevkAciklama
,0 as KalanTaksit
,'' as KayitTarihi, '' as sFiyatTipi
,0 nIskontoYuzdesi , 0 nDipIskontoYuzdesi
from tbMusteri inner Join (Select distinct tbAlisVeris.nMusteriID from
tbAlisVeris ,tbMusteri
where dteFaturaTarihi Between '01/01/1900' and '31/12/2078 'and
tbMusteri.nMusteriID = tbAlisVeris.nMusteriID and lKodu = 8060242
) as tbTemp on tbMusteri.nMusteriID = tbTemp.nMusteriID
, tbFisTipi, tbAlisVeris, tbDepo, tbTaksit
LEFT outer join tbOdeme on tbOdeme.nTaksitID=tbTaksit.nTaksitID
Where tbTaksit.nAlisverisID = tbAlisVeris.nAlisverisID and
tbALisveris.sFisTipi = tbFisTipi.sFisTipi and
tbALisveris.sMagaza = tbDepo.sDepo
and tbMusteri.nMusteriID = tbAlisVeris.nMusteriID and lKodu = 8060242
group by tbTaksit.nTaksitId,tbAlisVeris.nGirisCikis ,tbMusteri.lKodu,tbMusteri.sAdi ,tbMusteri.sSoyadi,dteTarihi,lTutari
Having lTutari - IsNull(sum(tbOdeme.lOdemeTutar), 0) <> 0
) as a group by
GirisCikis,lKodu, sMusteriAdi, dteTarih, fisTipi, lNo, sKodu, sStokAciklama, Miktar,
Fiyat, Iskonto, lNetTutar, OdemeTutar , OdemeTipi, SaticiRumuzu, KasiyerRumuzu,
Teslimatci , AlisverisiYapan, TaksitTarihi, OdemeAciklama, Tipi
Order By lKodu,dteTarih,GirisCikis,fisTipi,lno,Tipi,TaksitTarihi,tbAlisVeris.nAlisverisId ,tbstokFisidetayi.nIslemId
Gönderildi : 23/02/2010 19:56
güncelleme ile (exeler ve sorgular) çözülecektir.
Gönderildi : 07/03/2010 05:01