-
[SQL] 조건문을 활용한 특정 칼럼 조회하기Data Analysis/SQL 2023. 12. 15. 22:23반응형
Table of Contents
- Question
- Answer
- Reference
Question
Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.
The CITY table is described as follows:
Answer
Question quest us how to query the NAME field for all America cities. And it tell us they have populations larger than 120000. So, We use "Condition Filtering".
MYSQL :
SELECT NAME FROM CITY WHERE POPULATION > 120000 AND COUNTRYCODE = 'USA'
ORACLE:
SELECT NAME FROM CITY WHERE POPULATION > 120000 AND COUNTRYCODE = 'USA'
Reference
"Condition Filtering", MySQL, https://dev.mysql.com/doc/refman/8.0/en/condition-filtering.html
"About SQL Conditions", Oracle, https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/About-SQL-Conditions.html
Revising the Select Query", hackerrank, https://www.hackerrank.com/challenges/revising-the-select-query/
반응형'Data Analysis > SQL' 카테고리의 다른 글
[SQL] 짝수와 홀수인 조건으로 조회하기 (1) 2023.12.16 [SQL] 조건문을 활용한 모든 데이터 조회하기 (1) 2023.12.10 [SQL] 날짜 함수를 이용하여 특정 기간 데이터 조회하기 (4) 2023.06.16 [SQL] Windows에서 MariaDB root 계정 분실 시 (2) 2023.04.05 [SQL] SQL(Structured Query Language)이란? (2) 2023.03.23