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 2008 Forums
 Transact-SQL (2008)
 Assigning SEQUENCE

Author  Topic 

ben_53
Yak Posting Veteran

67 Posts

Posted - 2011-07-28 : 15:31:12
Hi,

I want to assign the sequence for a table with 4 columns.
col1 is identity, col4 is named seq.

now, col2 have only 4 values,
Apple,Banana,Strawberry & Blueberry.

col3 can have 3 vales,
LA, SF & NY.

Business logic:
sequence should be first according to col1
Banana>Blueberry>Apple>Strawberry

then according to col2 depending on col1
for banana col2 order = NY>LA>SF
for Blueberry, order = LA>SF>NY
and so on...

So, It should look like:

Banana NY 0001
Banana LA 0002
Banana SF 0003
Blueberry LA 0004
Blueberry SF 0005
Blueberry NY 0006 and so on...

Kindly write a general query for this.
mine is not working accordingly.

Thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-07-28 : 15:47:23
Dupe: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=163633
Go to Top of Page
   

- Advertisement -