Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
oznur
Starting Member
2 Posts |
Posted - 2007-04-03 : 13:46:41
|
these are my codes and i have a problem withinthe problem is: before "union all" command execution everything is working good;output is like:AAA 1 xxxx 2 rrrr 3 kkkkBBB 1 yyyy 2 ppppwhen i add some codes after "union all" command i dont get correct outputoutput is like:AAA 1 xxxx 2 rrrr 3 kkkk 1 kkkkBBB 1 yyyy 1 pppp Codes:select adi,firma_adi,sum(tlmiktari) as tutartl,firma_id1,musteri_id,rank=( select count(*) from sigarapazT t2 where t2.firma_id1=t1.firma_id1 and t2.musteri_id<=t1.musteri_id)from sigaraPazT t1,musterit B,firmaT c,faturaT dWHERE t1.musteri_id*=b.kodu and t1.firma_id1*=c.firma_id and t1.musteri_id*=d.musterikodugroup by musteri_id,firma_adi,adi,firma_id1having sum(tlmiktari)>0union allselect adi,firma_adi,sum(tlmiktari) as tutartl,firma_id2,musteri_id,rank=( select count(*) from sigarapazT t2 where t2.firma_id2=t1.firma_id2 and t2.musteri_id<=t1.musteri_id)from sigaraPazT t1,musterit B,firmaT c,faturaT dWHERE t1.musteri_id*=b.kodu and t1.firma_id2*=c.firma_id and t1.musteri_id*=d.musterikodugroup by musteri_id,firma_adi,adi,firma_id2having sum(tlmiktari)>0order by firma_adi,tutartl descafter these codes execution the output should be like:AAA 1 xxxx 2 rrrr 3 kkkkBBB 1 yyyy 2 pppp |
|
|
|
|
|
|