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
 QUERY FOR COMBINATION

Author  Topic 

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-10-20 : 08:27:19
Hi


create table #tmp(ID1 int, id2 int)

Insert into #tmp

SELECT 1 , 98 UNION ALL
SELECT 1 , 97 UNION ALL
SELECT 1 , 97 UNION ALL
SELECT 1 , 97 UNION ALL
SELECT 1 , 97 UNION ALL
SELECT 1 , 96 UNION ALL
SELECT 1 , 96 UNION ALL
SELECT 1 , 96 UNION ALL
SELECT 1 , 95 UNION ALL
SELECT 1 , 94 UNION ALL
SELECT 2 , 98 UNION ALL
SELECT 2 , 98 UNION ALL
SELECT 2 , 98 UNION ALL
SELECT 2 , 97 UNION ALL
SELECT 2 , 97 UNION ALL
SELECT 2 , 97 UNION ALL
SELECT 2 , 97 UNION ALL
SELECT 2 , 96 UNION ALL
SELECT 2 , 96 UNION ALL
SELECT 2 , 95 UNION ALL
SELECT 3 , 98 UNION ALL
SELECT 3 , 98 UNION ALL
SELECT 3 , 98 UNION ALL
SELECT 3 , 97 UNION ALL
SELECT 3 , 96 UNION ALL
SELECT 3 , 96 UNION ALL
SELECT 3 , 96 UNION ALL
SELECT 3 , 95 UNION ALL
SELECT 3 , 95 UNION ALL
SELECT 3 , 94 UNION ALL
SELECT 4 , 98 UNION ALL
SELECT 4 , 97 UNION ALL
SELECT 4 , 97 UNION ALL
SELECT 4 , 97 UNION ALL
SELECT 4 , 96 UNION ALL
SELECT 4 , 96 UNION ALL
SELECT 4 , 96 UNION ALL
SELECT 4 , 95 UNION ALL
SELECT 4 , 95 UNION ALL
SELECT 4 , 94 UNION ALL
SELECT 5 , 98 UNION ALL
SELECT 5 , 97 UNION ALL
SELECT 5 , 97 UNION ALL
SELECT 5 , 97 UNION ALL
SELECT 5 , 97 UNION ALL
SELECT 5 , 97 UNION ALL
SELECT 5 , 96 UNION ALL
SELECT 5 , 96 UNION ALL
SELECT 5 , 95 UNION ALL
SELECT 5 , 94


I have table data like this...

so i need to find out the id2 columns the combination of same order data with each id1 value(group by id1)

which means


1 , 98
1 , 97
1 , 97
1 , 97
1 , 97
1 , 96
1 , 96
1 , 96
1 , 95
1 , 94



I need to find out the entire table is there any same order of data repeated in table...so i need to each combination..only for id2 values with same order..

please help out


sorry about my english...

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-10-20 : 11:48:44
I'm not sure that I understand what your requirements are. What is teh expected output from the data you posted?
Go to Top of Page
   

- Advertisement -