You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query a list of CITY and STATE from the STATION table.
Query
SELECT CITY,
STATE
FROM STATION;
Output
CITY
STATE
Values depend on records present in STATION table
Question 2
Question
Let N be the number of CITY entries in STATION, and let N' be the number of distinct CITY names in STATION.
Find:
N - N'
Query
SELECTCOUNT(CITY) -COUNT(DISTINCT CITY) AS DIFFERENCE
FROM STATION;
Output
DIFFERENCE
Depends on table data
Question 3
Question
Query the list of CITY names starting with vowels (a, e, i, o, u).
Query
SELECT DISTINCT CITY
FROM STATION
WHERELOWER(CITY) LIKE'a%'ORLOWER(CITY) LIKE'e%'ORLOWER(CITY) LIKE'i%'ORLOWER(CITY) LIKE'o%'ORLOWER(CITY) LIKE'u%';
Output
CITY
Cities starting with vowels
Question 4
Question
Query the list of CITY names from STATION whose second character is a vowel.
Query
SELECT DISTINCT CITY
FROM STATION
WHERELOWER(CITY) LIKE'_a%'ORLOWER(CITY) LIKE'_e%'ORLOWER(CITY) LIKE'_i%'ORLOWER(CITY) LIKE'_o%'ORLOWER(CITY) LIKE'_u%';
Output
CITY
Cities with vowel as second character
Question 5
Question
Query the list of CITY names from STATION that do not start with vowels.
Query
SELECT DISTINCT CITY
FROM STATION
WHERELOWER(CITY) NOT LIKE'a%'ANDLOWER(CITY) NOT LIKE'e%'ANDLOWER(CITY) NOT LIKE'i%'ANDLOWER(CITY) NOT LIKE'o%'ANDLOWER(CITY) NOT LIKE'u%';
Output
CITY
Cities not starting with vowels
EMPLOYEE Table
Table Structure
Column
Data Type
employee_id
Integer
name
String
months
Integer
salary
Integer
Question 6
Question
Display employee names whose salary is greater than 2000 and who have worked for less than 10 months.
Sort the result by employee_id in ascending order.
Query
SELECT name
FROM Employee
WHERE salary >2000AND months <10ORDER BY employee_id ASC;
Output
NAME
Depends on Employee table data
CITY Table
Table Structure
Field
Type
ID
NUMBER
NAME
VARCHAR2(17)
COUNTRYCODE
VARCHAR2(3)
DISTRICT
VARCHAR2(20)
POPULATION
NUMBER
COUNTRY Table
Table Structure
Field
Type
CODE
NUMBER
CONTINENT
VARCHAR2(17)
REGION
VARCHAR2(3)
SURFACEAREA
VARCHAR2(20)
INDEPYEAR
NUMBER
POPULATION
NUMBER
LIFEEXPECTANCY
VARCHAR2(4)
GNP
NUMBER
GNPOLD
VARCHAR2(9)
LOCALNAME
VARCHAR2(44)
GOVERNMENTFORM
VARCHAR2(44)
HEADOFSTATE
VARCHAR2(32)
CAPITAL
VARCHAR2(4)
CODE2
VARCHAR2(2)
Question 7
Question
Given the CITY and COUNTRY tables, query the sum of populations of all cities where the continent is Asia.
Query
SELECTSUM(city.population) AS TOTAL_POPULATION
FROM city
INNER JOIN country
ONcity.countrycode=country.codeWHEREcountry.continent='Asia';