Skip to content
Advertisement

SQL query to display column values as column name in table

I have a field name ‘Title’ from table ‘Greeting’. Title field in UI might come as FirstName or LastName or combination of both.

Greeting table looks like:

I need to write a SQL Query to find which has Title FirstName only, LastName only and both FirstName and LastName and display in below table format. Create column name as FirstName and lastName and indicate by ‘Yes’ if that displayed and ‘No’ if not displayed.

I wrote below query and got the individual information of the ‘Title’ but not able to get column values as table column name format. Could you please help me to get output data in that table format

Advertisement

Answer

I tried ‘pivot’ and that helped me to get get output data in that table format

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