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
 General SQL Server Forums
 New to SQL Server Programming
 Need help to query

Author  Topic 

SQLBEGINNERFRENCH
Starting Member

2 Posts

Posted - 2010-08-04 : 05:56:19
Sorry for my english. I'm from France
I discover your forum and try to find a solution
I don't succeed to create my query : select of all table1 and adding all items which have same group in table2

TABLE1
ITEMT1 QTYT1 GROUPT1
item1 - 2 - A
item2 - 1 - Null
item3 - 3 - B

TABLE2
ITEMT2 - GROUPT2
item1 - A
itemT2N4 - A
itemT2N5 - A
item3 - B
itemT2N6 - B
itemT2N7 - C

I want to obtain this : My table 1 contain item with group A and B, So I want to add items of Table2 which have group A and B
item1 - 2 - A
item2 - 1 - Null
item3 - 3 - B
itemT2N4 - - A
itemT2N5 - - A
itemT2N6 - - B

If you help me, it will be great pleasure.
Thanks

Sachin.Nand

2937 Posts

Posted - 2010-08-04 : 06:06:04
Select T1.*,T2.* from TABLE1 T1
Left Join TABLE1 T2 on T1.GROUPT1=T2.GROUPT2



Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

SQLBEGINNERFRENCH
Starting Member

2 Posts

Posted - 2010-08-04 : 06:46:04
Thank You IDERA,

I'm very beginner in SQL Query !!

The test seems to be good. I'll try to adapt and control with more datas

'Et voilà !'

Merci
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-08-04 : 07:07:45
quote:
Originally posted by SQLBEGINNERFRENCH

Thank You IDERA,

I'm very beginner in SQL Query !!

The test seems to be good. I'll try to adapt and control with more datas

'Et voilà !'

Merci



You are welcome.Just stick around this site & I am sure you wont be a beginner for to long.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page
   

- Advertisement -