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
 SQL Server Development (2000)
 Need help with a dynamic T-sql Query in my stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-22 : 06:50:10
Reo writes "I have a table with two columns. Values of both columns are dynamic in nature i.e. i don't know what values or how many rows this table could have. I need to populate a 3rd column based on the two columns.

Table Style

COL-A(varchar) - COL-B(varchar)

C1 A
C1 B
C2 A
C2 B
C3 A
C4 C
C5 C


My resultset should be

Col-A COl-B Col-C

C1 A 1
C1 B 1
C2 A 1
C2 B 1
C3 A 2
C4 C 3
C5 C 3

Note that the values of C1 & C2 are unique so i begin my count with 1 , followed by C3 as 2 . Moving further down C4 & C5 happen to have unique values so, they would be 3. And move further in the table 4,5,6.......etc.

How can i poulate the results of Col-C from Col-A & Col-B.
Any help would be appreciated. Thank you"

mpetanovitch
Yak Posting Veteran

52 Posts

Posted - 2005-08-22 : 14:17:06
please explain how col-c is populated again.

Mike Petanovitch
Go to Top of Page
   

- Advertisement -