Completing the where clause in sql server -


i have table kyc3 there walletno, status , rank columns present. rank columns filled 0. while status column has following data: accepted, rejected, registered , scanned. want put value each status in rank column

accepted = 1, rejected = 2, registered = 3 , scanned = 4

i wrote following query not understand how complete it:

insert kyc3([rank]) select status_ kyc3 

i understand need put clause indicate logic data population. should write?

you can use update fill cell of existing row.

update kyc3 set rank = case when status = 'accepted' 1                 when status = 'rejected' 2                 when status = 'registered' 3                 when status = 'scanned' 4            end 

use insert creating new rows.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -