Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

equivalent SQL Queries of index match (excel) to update column in existing table

$
0
0

0

I need to update an existing table by adding a new column. Below is the sample data for the first table which needs to be updated with the new column(Ticket_No_Calc).


And here is the sample data of the second table.


In Excel, I use this formula in order to get the output for the new column (Ticket_No_Calc).

Text
=IFERROR(IF(D2="MKT",INDEX(Second!A:A,MATCH(First!B2,Second!B:B,0),0),INDEX(Second!A:A,MATCH(First!C2,Second!B:B,0),0)),INDEX(Second!A:A,MATCH(First!A2,Second!B:B,0),0)) 

I am not sure on how to translate this formula into SQL command. Could someone please help me with this please

Thank you.



Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>