Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Generating Combination Numbers Expand / Collapse
Author
Message
Posted Thursday, July 29, 2010 1:01 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 19, 2010 10:52 PM
Points: 30, Visits: 213
Hi friends,

I have a scenario where the table values are

ID First Second
1 6 2
1 4 2
1 2 2
2 6 1
2 4 1
2 2 1

From this table I want to generate a combination where Next ID values is max(previous ID) ie 3 and a combination of first and second which didnt come in the Previous combination, for eg

3 6 2
3 4 1
3 2 2


Can any solve this issue...help appreciated...
Post #960522
Posted Thursday, July 29, 2010 3:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 7:06 AM
Points: 2,404, Visits: 7,311
varunfilim (7/29/2010)
Hi friends,

I have a scenario where the table values are

ID First Second
1 6 2
1 4 2
1 2 2
2 6 1
2 4 1
2 2 1

From this table I want to generate a combination where Next ID values is max(previous ID) ie 3 and a combination of first and second which didnt come in the Previous combination, for eg

3 6 2
3 4 1
3 2 2


Can any solve this issue...help appreciated...


Umm, why not: -

3 6 2
3 4 2
3 2 2

??

Just want to understand the actual requirement before I spend some time.



Not a DBA, just trying to learn

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better, quicker answers on SQL Server performance related questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/



If you litter your database queries with nolock query hints, are you aware of the side effects?
Try reading a few of these links...

(*) Missing rows with nolock
(*) Allocation order scans with nolock
(*) Consistency issues with nolock
(*) Transient Corruption Errors in SQL Server error log caused by nolock
(*) Dirty reads, read errors, reading rows twice and missing rows with nolock


LinkedIn | Blog coming soon (for sufficiently large values of "soon" )!
Post #960564
Posted Thursday, July 29, 2010 3:21 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 5:25 AM
Points: 3,683, Visits: 4,817
Please provide the DDL for the tables and examples that you have already tried

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #960568
Posted Thursday, April 28, 2011 4:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 16, 2013 1:16 PM
Points: 7, Visits: 120
Hi,

I Have similar requirement. If anyone solve this, pls let me know. Explanation of the problem.
Consider i have two columns with combinations of numbers. I want to pick the genuine combinations of numbers which doesnt involve in other valid conbinations. For ex.,

Num1 Num2
6 2
2 1
2 3
4 6
3 1
8 9
3 9
6 8


My result should be

6 2
3 1
8 9


Can this be done without using loops...
Post #1100095
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse