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 |
|
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 TL100 01 001 TL KASA 1500 TL102 01 001 TL BANKA 1200 TL1020 10 01 TL BANKA 1500 TLbut I must do the make100 kasa 10100 01 tl kasa 10100 01 001 merkez kasa 10320 saticilar 5320 01 m.saticilar 5320 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. |
 |
|
|
UNSAL
Starting Member
17 Posts |
|
|
UNSAL
Starting Member
17 Posts |
Posted - 2009-03-04 : 02:05:52
|
HELP ME UNSAL OSMA/TURKEY/ANTALYA |
 |
|
|
UNSAL
Starting Member
17 Posts |
Posted - 2009-03-05 : 09:35:47
|
| can fix the problem helpUNSAL OSMA/TURKEY/ANTALYA |
 |
|
|
|
|
|
|
|