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)
 Using Group BY

Author  Topic 

saidev
Posting Yak Master

101 Posts

Posted - 2006-08-14 : 18:31:25
Hi Guys,

I have two tables A and B, and i want to group by using the tbl A (i,e 1---> 100, 2 -----> 200, and so on.) can you guys
help me with the Query. Appreciate your help
Thanks,



A B
1 100
2 100
3 100
4 200
5 200
6 200

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-14 : 18:49:11
I have no idea what you are after.

Please try again to explain what you want, with table structures, sample data and your expected results.


CODO ERGO SUM
Go to Top of Page

saidev
Posting Yak Master

101 Posts

Posted - 2006-08-14 : 19:00:18
Here is another example.

if i select 1003 in tbl-A then i need to pick all '1003's in tbl- B and so on...
Thanks

Tbl-A

id group

1003 GLOBAL MARKETING RESOURCE
1005 DDB NEEDHAM (IL)




Tbl-B

id1 group1

1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1003 GENERAL-CASH
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
1005 General (initial load)
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-14 : 19:43:51
So what are your expected results?


CODO ERGO SUM
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-15 : 02:16:13
Maybe an INNER JOIN will suffice?

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

saidev
Posting Yak Master

101 Posts

Posted - 2006-08-15 : 11:01:48
If i select 1003 in tbl A then i need to get all 1003's in tbl B
Thanks,
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-15 : 11:46:24
[code]select *
from tblA inner join tblB
on tblA.id = convert(int, tblB.id1)
where tblA.id = 1003[/code]


KH

Go to Top of Page
   

- Advertisement -