YOUR AD GOES HERE

day 45 | 50 Days of SQL | SELECT AS FROM UNION | SQL Query

Published 10, Dec 2023

SAHAS H S


Description:
Merging Customer and Supplier Data with Table Origin Column

You have access to two tables: customers and suppliers. Your objective is to:

Select the columns city, company_name, and contact_name from both tables.
Merge the results together.
Add an additional column in the result set to specify the origin of each record. This column should contain either 'customers' or 'suppliers' to indicate from which table the record came. Make sure name of this column is relationship
Concepts to Consider
Think about how you can merge results from two separate queries.
Consider how to add static values to a result set for classification purposes.
Ensure your final query is structured and formatted correctly. Once you believe you have the correct solution, submit your query for validation. Best of luck!

Query:
select city,company_name,contact_name,'customers' as relationship from customers union select city,company_name,contact_name,'suppliers' as relationship from suppliers
#codedamn #challenge #solution #sql #50dayschallenge #query #simple

Releted More Videos

You May Also Like

YOUR AD GOES HERE

YOUR AD GOES HERE