SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Generating Combination Numbers


Generating Combination Numbers

Author
Message
varunfilim
varunfilim
SSC-Enthusiastic
SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)

Group: General Forum Members
Points: 108 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...
Cadavre
Cadavre
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14665 Visits: 8510
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.


Forever 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


Craig Wilkinson - Software Engineer
LinkedIn
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24797 Visits: 7501
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”
dinesh.spn
dinesh.spn
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 140
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...
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search