lundi 4 janvier 2016

retrieve data based on derived column

How to rewrite the bellow code as working sql. I need to retrieve 'item' from another table based on my new 'newcol' the code is. select s.code,o.[work name],case when o.[work name] is null then s.code else o.[work name] end newcol,item=(select item from table1 where table1.code=newcol) from shoplog s left outer join odc o on o.barcode=s.code

Aucun commentaire:

Enregistrer un commentaire