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.
| Author |
Topic |
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-29 : 16:21:22
|
| I have a table with 5 columns.col1 = ID (int)col2 = fruits (8 values)col3 = Batch (01, 02, 03, .... N )col4 = can have 5 values (say Xvalue) (111,222,333,444,555)col5 = sequence(int).Logic: Fruits are arranged in order.Apple>Banana>Mango>pineapple>Guava>Orange etc... (8 total)Every fruit can have different batch numbers (01,05,45, etc..)Now every batch can have 5 possible xValues.I want to assign the sequence for the data like: Data:1 Banana 02 555 2 Apple 01 3333 Apple 01 1114 Apple 02 5555 Banana 01 555ID 3 should be 1st in seqID 2 should be secondand so on.....Result:col1(id) col2 col3(batch) col4(xvalue) col5(seq) 3 Apple 01 111 01 2 Apple 01 333 02 4 Apple 02 555 03 5 Banana 01 555 04 1 Banana 02 555 05Again It should sort according to fruit Name,then it should look for batch and then xValue and then assign the sequence.Any help would be appreciated.Thanks |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
|
Ghanta
Yak Posting Veteran
96 Posts |
Posted - 2011-07-29 : 16:29:55
|
| Apple, Banana, NY, LA.. this looks like a HW problem :) |
 |
|
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-29 : 16:31:42
|
| @ TG:Sorry Lets Change col4 values to ( B101, Q105, S096, J012 and L123 )I want the sequence for col4 as (Q105 > B101 > J012 > L123 > S096)now what technique should I use ?I know CASE, But where ? |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-29 : 16:39:29
|
| no, That post Addresses a different scenario. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-07-29 : 16:47:54
|
| Ok then - to avoid that ongoing back and forth like the other thread please post DDL/DML (code to create and populate a temp table) for enough sample data to illustrate your problem. Then include the desired output based on your sample data.Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|