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 |
raj.prabhu001
Starting Member
16 Posts |
Posted - 2012-04-06 : 23:52:47
|
i have to update rows for a table of col1 based value in upper row.if the row is null or balnk or 0 then it should be updated with value of upper row i.e. previous row value. as shown belowcol1----- 12045561223so in the above case 0 value shoud be upadted with 12 androws which are blank below 56 value should be upadated with 56 and so on.please suggest the query for the same. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-06 : 23:57:51
|
do you've an id field to determine the order? without specifying in terms of column, there's no concept of order in sql table------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
raj.prabhu001
Starting Member
16 Posts |
Posted - 2012-04-07 : 00:04:29
|
we are not having any id field row but you can add new unique column. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-07 : 00:13:49
|
what do you mean by you can add? so currently table doesnt have unique valued column?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
raj.prabhu001
Starting Member
16 Posts |
Posted - 2012-04-07 : 01:14:03
|
yes there customerid column but it is not ordered in the database. |
 |
|
namman
Constraint Violating Yak Guru
285 Posts |
Posted - 2012-04-07 : 22:07:33
|
As visakh16 say, we must have a column indecating order of rows. Without that, we dont know which one is previous row, previous row of 0 may be 45, not 12. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-08 : 18:08:31
|
quote: Originally posted by raj.prabhu001 yes there customerid column but it is not ordered in the database.
then there's no way to guarantee the order------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|