34. Merging Fields into a Single Row

This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
 

Given the following tables:
Customer table – each row specifies the customer number, name, and city of residence.

CREATE TABLE Customers   
(CustomerID int identity(1,1),   
 CustomerName varchar(25),   
 CityID  int)  
GO  

34-2

City table – this table contains the names of cities for the customer table.

CREATE TABLE Cities   
(CityID int identity(1,1),   
 CityName varchar(25))  
GO   

34-3

To read more

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…