티스토리 뷰

Programming/DATABASE

[SQL] 기본 SQL 찾기

RosyPark 2022. 1. 7. 11:02

 

 

1. Select All 

SELECT * 
FROM CITY;

 

2. Weather Observation Station 1

SELECT CITY,STATE
FROM STATION;

 

3. Revising the Select Query I

SELECT *
FROM CITY
WHERE POPULATION > 100000 AND COUNTRYCODE = 'USA';

4. Select By ID

SELECT *
FROM CITY
WHERE ID = '1661';

 

 

5. Weather Observation Station 6

Q. Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates. 

SELECT DISTINCT city
From station
WHERE city LIKE 'a%'
OR city LIKE 'e%'
OR city LIKE 'o%'
OR city LIKE 'i%'
OR city LIKE 'u%';

 

 

6.  Weather Observation Station 12 

Q. 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.

SELECT DISTINCT city
From station
WHERE city NOT LIKE 'a%'
AND city NOT LIKE 'e%'
AND city NOT LIKE 'o%'
AND city NOT LIKE 'i%'
AND city NOT LIKE 'u%'
AND city NOT LIKE '%a'
AND city NOT LIKE '%e'
AND city NOT LIKE '%o'
AND city NOT LIKE '%i'
AND city NOT LIKE '%u';

 

 

 


1. Revising Aggregations - Averages

 

 

2. 

 

 

 


SQL사이트

- https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all 

 

SQL Tryit Editor v1.6

WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object. WebSQL is supported in Chrome, Safari, Opera, and Edge(79). If you use another browser you will still be able to use our Try SQL Editor, but a different ver

www.w3schools.com

 

https://www.hackerrank.com/challenges/weather-observation-station-1/problem

 

Weather Observation Station 1 | HackerRank

Write a query to print the CITY and STATE for each attribute in the STATION table.

www.hackerrank.com

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG more
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함