The document discusses SQL JOIN and SUBQUERY operations. It provides examples of using subqueries to find cities and countries that meet certain population and GNP criteria. It also gives examples of JOIN queries to retrieve related data from multiple tables based on shared countrycodes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
30 views10 pages
Lab 3
The document discusses SQL JOIN and SUBQUERY operations. It provides examples of using subqueries to find cities and countries that meet certain population and GNP criteria. It also gives examples of JOIN queries to retrieve related data from multiple tables based on shared countrycodes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10
SQL
JOIN and SUBQUERY
Subquery • Display city name, district and population from table city where population is greater than Kelang’s population and country code is MYS. (Note: Assume that Kelang population is not known)
SELECT name, district, population
FROM city WHERE countrycode = 'MYS' and population > (SELECT population FROM city WHERE countrycode = 'MYS' and name = 'Kelang'); Subquery - Output Subquery • Display country name and GNP for all countries that have GNP greater than Australia’s GNP. (Note: GNP Australia is unknown)
SELECT name, GNP
FROM country WHERE GNP > (SELECT GNP FROM country WHERE name = 'Australia'); Subquery - output Join • Display countrycode, country name, language, isofficial and percentage from table Country and Countrylanguage where Countrycode = MYS