|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-12-02 : 07:57:40
|
| Paul Ross writes "Hi,I have a very interesting challenge.I have a table where there are different combinations of the integer values of the columns x, y, w, and z. Each of these combinations can be assigned to up four letters A, B, C and D (one per row).For example, two possible combinations are:1, 3, 4, 5 (in other words, x =1, y = 3, w = 4, and z = 5)and4, 6, 7, 8 (n other words, x =4, y = 6, w = 7, and z = 8)These combinations can be assigned to up four letters, one per row. For example,1,3,4,5,A 1,3,4,5,B1,3,4,5,C4,6,7,8,A4,6,7,8,CIn the example above, there are five records where the first combination (1,3,4,5) has been assigned to values A, B, and C. The second combination (4,6,7,8) has been assigned to values A and C.Goal: to insert in the table the missing assignments to letters for each existing combination, possibly in an elegant way, with only one SQL statement (if more SQL statements are needed, it is ok, but it would be less elegant). Also, if possible, using T-SQL syntax (MS SQL Server 2000).In other words, the missing assignments in the example above would be:1,3,4,5,D4,6,7,8,B4,6,7,8,DAny help would be appreciated.Thanks in advance,Paul" |
|