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)
 Missing combinations

Author  Topic 

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)
and
4, 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,B
1,3,4,5,C
4,6,7,8,A
4,6,7,8,C

In 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,D
4,6,7,8,B
4,6,7,8,D

Any help would be appreciated.

Thanks in advance,
Paul"

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2005-12-02 : 08:20:39
Duplicate of this thread:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=58256
Go to Top of Page
   

- Advertisement -