vendredi 27 août 2021

SQL add column based on if statement

I have a table with a 4 character (col1) that I would like to:

  • split in half
  • use an if statement to recode the left 2 characters as specific integers
  • concat left onto rght (separated by '.') to generate the fin column below.
col1 left rght fin
xx01 xx 01 01.1
xy01 xy 01 01.2
xz01 xz 01 01.3

Bit of a SQL noob so appreciate any advice. Thanks!

Aucun commentaire:

Enregistrer un commentaire