Sign up and we'll send you the best freelance opportunities straight to
your inbox.
We're building the largest freelancing marketplace for people like you.
Problem: List all unique countries for customers and suppliers.
SELECT Country
FROM Customer
UNION
SELECT Country
FROM Supplier
Result: 25 Records
Country
Argentinia
Australia
Austria
Belgium
UNION ALL
SUPPLIER
Id
CompanyName
ContactName
City
Country
Phone
Fax
CUSTOMER
Id
FirstName
LastName
City
Country
Phone
Problem: List all countries for customers and suppliers, including duplicates,
sorted by country.
SELECT Country
FROM Customer
UNION ALL
SELECT Country
FROM Supplier
ORDER BY Country
Result: 120 Records
Country
Argentina
Argentina
Argentina
Autralia
Autralia
Austria
Austria
Belgium
Belgium
UNION Multiple Columns
SUPPLIER
Id
CompanyName
ContactName
City
Country
Phone
Fax
CUSTOMER
Id
FirstName
LastName
City
Country
Phone
Problem: List all contacts with full details, both customers and suppliers.
SELECT 'Customer' As Type,
FirstName + ' ' + LastName AS ContactName,
City, Country, Phone
FROM Customer
UNION
SELECT 'Supplier',
ContactName, City, Country, Phone
FROM Supplier
Sign up and we'll send you the best freelance opportunities straight to
your inbox.
We're building the largest freelancing marketplace for people like you.