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 2000 Forums
 Transact-SQL (2000)
 Query Helping

Author  Topic 

daquoc
Starting Member

35 Posts

Posted - 2006-05-10 : 03:06:38
Hi experts
I have 3 table like this.
1. tbl_a
code day_a desc qty
A 29/01/06 Decla 1 100
B 25/02/06 Decla 1 50

2. tbl_b
code day_b desc qty
A 01/02/06 Input 1 50
A 02/02/06 Input 2 20
A 05/03/06 Input 3 30
B 26/02/06 Input 1 50

3. tbl_c
code day_c desc qty
A 02/02/06 Output 1 10
A 07/03/06 Output 2 20
A 08/03/06 Output 3 10
A 01/04/06 Output 4 10

How can I make 1 query to final tbl_d like this
Code Day_a Desc Qty Day_b Desc Qty Day_c Desc Qty
A 29/01 A1 100 01/02 Input 1 50 02/02 Output 1 10
02/02 Input 2 20 07/03 Output 2 20
05/03 Input 3 30 08/03 Output 3 10
01/04 Output 4 10
B 25/02 De B 50 26/02 Input 1 50 01/03 Output 1 10 03/03 Output 2 15
04/03 Output 3 15
05/03 Output 4 10

Thank
Quoc Duong


chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-10 : 03:19:25
Somthing like this

Select A.Code,A.Day_A,A.Desc,A.Qty,B.Day_A,B.Desc,B.Qty,C.Day_A,C.Desc,C.Qty
From Tbl_A A Inner Join Tbl_B B On A.Code = B.Code
Inner Join Tbl_C C On C.Code = B.Code

??

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-10 : 04:16:08
You should have primary or unique key in the tables to get proper result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -