Skip to content
Advertisement

SQL Query for getting the output as shown in the example shared

For this sample data:

And the query:

OUTPUT With above Query:

enter image description here

Required Output:

enter image description here

Notice the Null is required if no match, as shown in 4th row. The output must be display for all values in T1 and only values 184962 or 333 in M1 whichever is present and Null in M1 if value not present.

Advertisement

Answer

You can use APPLY :

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement