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.
SELECT DISTINCT CITY
FROM STATION
WHERE LEFT(CITY,1) NOT IN ("A", "E", "I", "O", "U") OR
RIGHT (CITY,1) NOT IN ("a", "e", "i", "o", "u")
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.
SELECT DISTINCT CITY
FROM STATION
WHERE LEFT(CITY,1) NOT IN ("A", "E", "I", "O", "U") AND
RIGHT (CITY,1) NOT IN ("a", "e", "i", "o", "u")
Query the Name of any student in STUDENTS who scored higher than 75 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.
SELECT Name
FROM STUDENTS
WHERE Marks > 75
ORDER BY RIGHT(Name,3), ID
Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order.
select name
from Employee
order by name
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. Sort your result by ascending employee_id.
select name
from Employee
where salary > 2000 and months < 10
order by employee_id
Query a count of the number of cities in CITY having a Population larger than 1000000
select count(ID)
from CITY
where POPULATION > 100000
Query the total population of all cities in CITY where District is California.
Input Format
select sum(POPULATION)
from CITY
where DISTRICT = "California"
Query the average population of all cities in CITY where District is California.
Input Format
select avg(POPULATION)
from CITY
WHERE DISTRICT = "California"
Query the average population for all cities in CITY, rounded down to the nearest integer.
select round(avg(POPULATION),0)
from CITY
Query the sum of the populations for all Japanese cities in CITY. The COUNTRYCODE for Japan is JPN.
select sum(POPULATION)
from CITY
where COUNTRYCODE = "JPN"
[11주차]해커랭크: 36~44 (0) | 2023.03.04 |
---|---|
[10주차]해커랭크: 26 ~ 35 (0) | 2023.03.03 |
[8주차]해커랭크 Basic Select 15 (0) | 2023.02.05 |
[7주차] 리트코드: Day5 ~ Day9(1407, 1158) (0) | 2022.12.12 |
[6주차]리트코드: day1 ~ day4 (0) | 2022.12.08 |