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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL GROUP SUM ?

Author  Topic 

UNSAL
Starting Member

17 Posts

Posted - 2009-02-27 : 09:03:04
combine the two tables this query is questioned.
I was questioned, but added that the date did not work the way you want.It looks like the following query is running.

100 01 001 TL KASA 1200 TL
100 01 001 TL KASA 1500 TL
102 01 001 TL BANKA 1200 TL
1020 10 01 TL BANKA 1500 TL

but I must do the make

100 kasa 10
100 01 tl kasa 10
100 01 001 merkez kasa 10
320 saticilar 5
320 01 m.saticilar 5
320 01 001 a firmasi 5







"select hp.HKODU, hp.HADI, ISNULL(SUM(fh.FBORC), (SELECT SUM(fh2.FBORC) FROM FISHRK as fh2 WHERE fh2.HKODU like hp.HKODU + '%')) as FBORC,ISNULL(SUM(fh.FALACAK),(SELECT SUM(fh2.FALACAK) FROM FISHRK as fh2 WHERE fh2.HKODU like hp.HKODU + '%')) as FALACAK,(CASE WHEN ISNULL(SUM(fh.FBORC- fh.FALACAK), (SELECT SUM(fh2.FBORC- fh2.FALACAK) FROM FISHRK as fh2 WHERE fh2.HKODU like hp.HKODU + '%')) > 0 THEN ISNULL(SUM(fh.FBORC- fh.FALACAK), (SELECT SUM(fh2.FBORC- fh2.FALACAK) FROM FISHRK as fh2 WHERE fh2.HKODU like hp.HKODU + '%')) ELSE 0 END) as BBakiye,(CASE WHEN ISNULL(SUM(fh.FBORC- fh.FALACAK), (SELECT SUM(fh2.FBORC- fh2.FALACAK) FROM FISHRK as fh2 WHERE fh2.HKODU like hp.HKODU + '%')) < 0 THEN ISNULL(SUM(fh.FBORC- fh.FALACAK), (SELECT SUM(fh2.FBORC- fh2.FALACAK) FROM FISHRK as fh2 WHERE fh2.HKODU like hp.HKODU + '%')) * -1 ELSE 0 END) as ABakiye from Hesap_Plan as hp left join FISHRK as fh on hp.HKODU = fh.HKODU WHERE GRUP IN ('A','K','M')and FTARIH>=@TARIH and FTARIH<=@TARIH2 and hp.HKODU like '[" + TextBox1.Text + "-" + TextBox2.Text + "]%' GROUP BY hp.HKODU, hp.HADI ORDER BY HKODU "


UNSAL OSMA/TURKEY/ANTALYA

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2009-03-01 : 07:14:36
Unsal, No one has answered your question because the question is not very clear.

You said you need to combine two tables. So do the following:
1. Describe the columns in the two tables.
2. Give some sample data in each table.
3. Give example of the output you want if you had that sample data in the table.

If you do that, I am sure that many people on these forums would try to help you.
Go to Top of Page

UNSAL
Starting Member

17 Posts

Posted - 2009-03-02 : 05:33:14
MY PROJE VISUAL BASIC.NET 2005 AND SQL SERVER 2005 made

proje sql script and jpeg link :

http://rapidshare.com/files/204336086/table_an_jpeg.rar.html

UNSAL OSMA/TURKEY/ANTALYA
Go to Top of Page

UNSAL
Starting Member

17 Posts

Posted - 2009-03-04 : 02:05:52
HELP ME

UNSAL OSMA/TURKEY/ANTALYA
Go to Top of Page

UNSAL
Starting Member

17 Posts

Posted - 2009-03-05 : 09:35:47
can fix the problem help

UNSAL OSMA/TURKEY/ANTALYA
Go to Top of Page
   

- Advertisement -