OiO.lk Blog SQL Update Set for a column
SQL

Update Set for a column


This is a sample table and I would like to update the column ‘TYPE’ as like the value which is there ‘STOCKIN’ /’STOCKOUT’ for the particular DOCNUM in each row.

Sample Table

CODE DOCNUM TYPE
Z01 NUM12 stockin
Z01 NUM12 null
Z01 NUM12 null
Z01 NUM12 null
Z01 NUM134 stockout
Z01 NUM134 null
Z01 NUM134 null
Z01 NUM134 null

Expected table

CODE DOCNUM TYPE
Z01 NUM12 stockin
Z01 NUM12 stockin
Z01 NUM12 stockin
Z01 NUM12 stockin
Z01 NUM134 stockout
Z01 NUM134 stockout
Z01 NUM134 stockout
Z01 NUM134 stockout

Please help me how can I update the column Type for each row as per the DOCNUM.



You need to sign in to view this answers

Exit mobile version