- Basic Select
- Revising the Select Query
- Weather Observation Station
- Weather Observation Station 1
- Weather Observation Station 2
- Weather Observation Station 3
- Weather Observation Station 4
- Weather Observation Station 5
- Weather Observation Station 6
- Weather Observation Station 7
- Weather Observation Station 8
- Weather Observation Station 9
- Weather Observation Station 10
- Weather Observation Station 11
- Weather Observation Station 12
- Weather Observation Station 13
- Weather Observation Station 14
- Weather Observation Station 15
- Weather Observation Station 16
- Weather Observation Station 17
- Weather Observation Station 18
- Weather Observation Station 19
- Weather Observation Station 20
- Higher Than 75 Marks
- Employees
- Advanced Select
- Aggregation
- Basic Join
- Alternative Queries
The CITY table is described as follows:
Column | Type |
---|---|
ID | NUMBER |
NAME | VARCHAR2(17) |
COUNTRYCODE | VARCHAR2(3) |
DISTRICT | VARCHAR2(20) |
POPULATION | Number |
Query all columns for all American cities in the CITY table with populations larger than 100000. The COUNTRYCODE for America is USA.
Query the NAME field for all American cities in the CITY table with populations larger than 120000. The COUNTRYCODE for America is USA.
Query all columns (attributes) for every row in the CITY table.
Query all columns for a city in CITY with the ID 1661.
Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN.
Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN.
The STATION table is described as follows:
Column | Type |
---|---|
ID | NUMBER |
CITY | VARCHAR2(21) |
STATE | VARCHAR2(2) |
LAT_N | NUMBER |
LONG_W | NUMBER |
where LAT_N is the northern latitude and LONG_W is the western longitude.
Query a list of CITY and STATE from the STATION table.
Query the following two values from the STATION table:
- The sum of all values in LAT_N rounded to a scale of 2 decimal places.
- The sum of all values in LONG_W rounded to a scale of 2 decimal places.
Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table.
Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.
Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates.
Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.
Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.
Query the list of CITY names from STATION that do not end with vowels. Your result cannot contain duplicates.
Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.
Query the list of CITY names from STATION that do not start with vowels and do not end with vowels. Your result cannot contain duplicates.
Query the sum of Northern Latitudes (LAT_N) from STATION having values greater than 38.7880
and less than 137.2345
. Truncate your answer to 4
decimal places.
Query the greatest value of the Northern Latitudes (LAT_N) from STATION that is less than 137.2345
. Truncate your answer to 4
decimal places.
Query the Western Longitude (LONG_W) for the largest Northern Latitude (LAT_N) in STATION that is less than 137.2345
. Round your answer to 4
decimal places.
Query the smallest Northern Latitude (LAT_N) from STATION that is greater than 38.7780
. Round your answer to 4
decimal places.
Query the Western Longitude (LONG_W) where the smallest Northern Latitude (LAT_N) in STATION is greater than 38.7780
. Round your answer to 4
decimal places.
Consider P subscript(1) (a,b)
and P subscript(2) (c,d)
to be two points on a 2D plane.
a
happens to equal the minimum value in Northern Latitude (LAT_N in STATION).b
happens to equal the minimum value in Western Longitude (LONG_W in STATION).c
happens to equal the maximum value in Northern Latitude (LAT_N in STATION).d
happens to equal the maximum value in Western Longitude (LONG_W in STATION).
Query the Manhattan Distance between points P subscript(1)
and P subscript(2)
and round it to a scale of decimal 4
places.
ConsiderP subscript(1) (a,b)
and P subscript(2) (c,d)
to be two points on a 2D plane where (a,b)
are the respective
minimum and maximum values of Northern Latitude (LAT_N) and (c,d)
are the respective minimum and maximum values of Western Longitude (LONG_W) in STATION.
Query the Euclidean Distance between points P subscript(1)
and P subscript(2)
and format your answer to display 4
decimal digits.
A median is defined as a number separating the higher half of a data set from the lower half.
Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to 4
decimal places.
Query the Name of any student in STUDENTS who scored higher than Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID.
The STUDENTS table is described as follows: The Name column only contains uppercase (A-Z) and lowercase (a-z) letters.
Column | Type |
---|---|
ID | Integer |
Name | String |
Marks | Integer |
Column | Type |
---|---|
EMPLOYEE_ID | INTEGER |
NAME | STRING |
MONTHS | INTEGER |
SALARY | INTEGER |
Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order.
Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than
$2000
per month who have been employees for less than 10
months. months. Sort your result by ascending employee_id.
Column | Type |
---|---|
A | INTEGER |
B | INTEGER |
C | INTEGER |
Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:
- Equilateral: It's a triangle with
3
sides of equal length. - Isosceles: It's a triangle with
2
sides of equal length. - Scalene: It's a triangle with
3
sides of differing lengths. - Not A Triangle: The given values of A, B, and C don't form a triangle.
You are given a table, BST, containing two columns: N and P, where N represents the value of a node in Binary Tree, and P is the parent of N.
Column | Type |
---|---|
N | INTEGER |
P | INTEGER |
Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node:
- Root: If node is root node.
- Leaf: If node is leaf node.
- Inner: If node is neither root nor leaf node.
Generate the following two result sets:
-
Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example:
AnActorName(A)
,ADoctorName(D)
,AProfessorName(P)
, andASingerName(S)
. -
Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format:
There are a total of [occupation_count] [occupation]s.
where[occupation_count]
is the number of occurrences of an occupation in OCCUPATIONS and[occupation]
is the lowercase occupation name. If more than one Occupation has the same[occupation_count]
, they should be ordered alphabetically. Note: There will be at least two entries in the table for each type of occupation.
The OCCUPATIONS table is described as follows:
Column | Type |
---|---|
NAME | STRING |
OCCUPATION | STRING |
The CITY table is described as follows:
Column | Type |
---|---|
ID | NUMBER |
NAME | VARCHAR2(17) |
COUNTRYCODE | VARCHAR2(3) |
DISTRICT | VARCHAR2(20) |
POPULATION | NUMBER |
The EMPLOYEES table is described as follows:
Column | Type |
---|---|
ID | INTEGER |
NAME | STRING |
SALARY | INTEGER |
The EMPLOYEE table is described as follows:
Column | Type |
---|---|
EMPLOYEE_ID | INTEGER |
NAME | STRING |
MONTHS | INTEGER |
SALARY | INTEGER |
Query the total population of all cities in CITY where District is California.
Query the average population for all cities in CITY, rounded down to the nearest integer.
Query a count of the number of cities in CITY having a Population larger than 100,000
.
Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize
her keyboard's 0
key was broken until after completing the calculation. She wants your help finding the difference between her
miscalculation (using salaries with any zeros removed), and the actual average salary.
Write a query calculating the amount of error (i.e.: actual - miscalculated
average monthly salaries), and round it up to the next integer.
We define an employee's total earnings to be their monthly salary x months
worked,
and the maximum total earnings to be the maximum total earnings for any employee in the EMPLOYEE table.
Write a query to find the maximum total earnings for all employees as well as the total number of employees
who have maximum total earnings. Then print these values as 2
space-separated integers.
Query the sum of the populations for all Japanese cities in CITY. The COUNTRYCODE for Japan is JPN.
Query the average population for all cities in CITY, rounded down to the nearest integer.
Query the difference between the maximum and minimum populations in CITY.
Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is 'Asia'.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
The CITY and COUNTRY tables are described respectively as follows:
Field | Type |
---|---|
ID | NUMBER |
NAME | VARCHAR2(17) |
COUNTRYCODE | VARCHAR2(3) |
DISTRICT | VARCHAR2(20) |
POPULATION | NUMBER |
Field | Type |
---|---|
CODE | VARCHAR2(3) |
NAME | VARCHAR2(44) |
CONTINENT | VARCHAR2(13) |
REGION | VARCHAR2(25) |
SURFACEAREA | NUMBER |
INDEPYEAR | VARCHAR2(5) |
POPULATION | NUMBER |
LIFEEXPECTANCY | VARCHAR2(4) |
GNP | NUMBER |
GNPOLD | VARCHAR2(9) |
LOCALNAME | VARCHAR2(44) |
GOVERNMENTFROM | VARCHAR2(44) |
HEADOFSTATE | VARCHAR2(32) |
CAPITAL | VARCHAR2(4) |
CODE2 | VARCHAR2(2) |
Julia asked her students to create some coding challenges. Write a query to print the hacker_id, name, and the total number of challenges created by each student. Sort your results by the total number of challenges in descending order. If more than one student created the same number of challenges, then sort the result by hacker_id. If more than one student created the same number of challenges and the count is less than the maximum number of challenges created, then exclude those students from the result.
The following tables contain challenge data:
- Hackers: The hacker_id is the id of the hacker, and name is the name of the hacker.
Column | Type |
---|---|
hacker_id | Integer |
name | String |
- Challenges: The challenge_id is the id of the challenge, and hacker_id is the id of the student who created the challenge.
Column | Type |
---|---|
challenge_id | Integer |
hacker_id | Integer |
P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):
* * * * *
* * * *
* * *
* *
*
Write a query to print the pattern P(20).
P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):
*
* *
* * *
* * * *
* * * * *
Write a query to print the pattern P(20).
Write a query to print all prime numbers less than or equal to . Print your result on a single line, and use the ampersand (&) character as your separator (instead of a space).