SQL Server 2005 update query based on same table -


i have table following fields: id_observation (pk), id_grading, id_obkind, data.

i'm having difficulty writing query update rows based on other rows within table.

if id_obkind = 9 , data = 'no' row has same id_grading id_obkind = 10 , data = null needs updated data = 0.

i have dozen different cases data needs changed depending on value of data specific id_obkind need nail down. each id_grading can have 120 rows, each different id_obkind.

i think work you. http://sqlfiddle.com/#!3/2eeaf/14

update thetable    set data=0  id_grading = (select id_grading                        thetable                       id_obkind=9                         , data='no')    , id_obkind=10    , data null 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -