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 |
|
WoodHouse
Posting Yak Master
211 Posts |
Posted - 2009-11-05 : 07:28:12
|
Hii have update query like this based on the number of recordsi have one more column weight value take the maximun order value in that table and passing the TOP valuefor exampleUpdate TOP (10) test_table set column = 'A'where column is nullbove top 10 update value is 'A' based on the maxmimum order valueso i will pass the TOP valueA=5B=3C=2samplesweight status 100 A90 A80 A70 A60 A50 B40 B30 B20 C10 C help me out |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-05 : 07:32:59
|
I'am not able to understand what you want - sorry. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-11-05 : 08:03:51
|
| I'll put my psychic powers to the test. Plus I need the posts to hit the 1000 mark!declare @table table (col1 int, col2 char(1))insert into @table(col1)SELECT 100 UNION-- ASELECT 90 UNION-- ASELECT 80 UNION--UNION-- ASELECT 70 UNION--ASELECT 60 UNION-- ASELECT 50 UNION-- BSELECT 40 UNION-- BSELECT 30 UNION-- BSELECT 20 UNION-- CSELECT 10 --C UPDATE tSET Col2 = CASE WHEN t1.Row between 1 and 5 THEN 'A' WHEN t1.Row between 6 and 8 THEN 'B' WHEN t1.Row between 9 and 10 THEN 'C' ENDFROM @table tINNER JOIN( select col1,[Row] = Row_number() over(order by col1 desc ) from @table) t1ON t.col1 = t1.col1select * from @tableJimEveryday I learn something that somebody else already knew |
 |
|
|
|
|
|