vendredi 17 juin 2016

Same Column check in Sql Insertion

I have table dom having these two columns(FLAT_AMOUNT,FLAT_PERCENTAGE)

So I just going to insert the table dom

Insert into Dom
   select
     CASE WHEN FLAT_PERCENTAGE = 0 THEN 0 END AS FLAT_AMOUNT
     CASE WHEN PN_TYPE = 'AD' THEN 0
     WHEN PN_TYPE = 'OD' THEN 1
     WHEN PN_TYPE IN('SB','FP','AM','G') THEN 2
     ELSE 0
  END AS FLAT_PERCENTAGE

I hope you got my point.Is there a possible way to check same column values in the table to make insert for other column?

Aucun commentaire:

Enregistrer un commentaire