- Table:
Products
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| product_id | int |
| low_fats | enum |
| recyclable | enum |
+-------------+---------+
product_id is the primary key (column with unique values) for this table.
low_fats is an ENUM (category) of type ('Y', 'N') where 'Y' means this product is low fat and 'N' means it is not.
recyclable is an ENUM (category) of types ('Y', 'N') where 'Y' means this product is recyclable and 'N' means it is not.
Write a solution to find the ids of products that are both low fat and recyclable.
Return the result table in any order.
제출한 쿼리 :
SELECT PRODUCT_ID
FROM PRODUCTS
WHERE LOW_FATS LIKE 'Y'
AND RECYCLABLE LIKE 'Y';
enum에 대해서

- Table:
Customer
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| name | varchar |
| referee_id | int |
+-------------+---------+
In SQL, id is the primary key column for this table.
Each row of this table indicates the id of a customer, their name, and the id of the customer who referred them.
Find the names of the customer that are not referred by the customer with id = 2.
Return the result table in any order.
제출한 쿼리 :
SELECT NAME
FROM CUSTOMER
WHERE REFEREE_ID <> 2
OR REFEREE_ID IS NULL;
- Table:
World
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| name | varchar |
| continent | varchar |
| area | int |
| population | int |
| gdp | bigint |
+-------------+---------+
name is the primary key (column with unique values) for this table.
Each row of this table gives information about the name of a country, the continent to which it belongs, its area, the population, and its GDP value.
A country is big if:
- it has an area of at least three million (i.e.,
3000000
km2), or
- it has a population of at least twenty-five million (i.e.,
25000000
).
Write a solution to find the name, population, and area of the big countries.
Return the result table in any order.
제출한 쿼리 :
SELECT NAME
, POPULATION
, AREA
FROM WORLD
WHERE AREA >= 3000000
OR POPULATION >= 25000000;
- Table:
Views
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| article_id | int |
| author_id | int |
| viewer_id | int |
| view_date | date |
+---------------+---------+
There is no primary key (column with unique values) for this table, the table may have duplicate rows.
Each row of this table indicates that some viewer viewed an article (written by some author) on some date.
Note that equal author_id and viewer_id indicate the same person.
Write a solution to find all the authors that viewed at least one of their own articles.
Return the result table sorted by id
in ascending order.
제출한 쿼리 :
SELECT DISTINCT AUTHOR_ID AS "ID"
FROM VIEWS
WHERE AUTHOR_ID = VIEWER_ID
ORDER BY ID
- Table:
Tweets
+----------------+---------+
| Column Name | Type |
+----------------+---------+
| tweet_id | int |
| content | varchar |
+----------------+---------+
tweet_id is the primary key (column with unique values) for this table.
This table contains all the tweets in a social media app.
Write a solution to find the IDs of the invalid tweets. The tweet is invalid if the number of characters used in the content of the tweet is strictly greater than 15
.
Return the result table in any order.
제출한 쿼리 :
SELECT TWEET_ID
FROM TWEETS
WHERE LENGTH(CONTENT) > 15;
오늘의 TMI
살려줘.... 진짜 인터넷 끊기는 것 때문에 미칠 것 같음; 공유기 바꾸고, 와이파이 드라이버 다시 깔고 별 짓을 해도 계속 끊김......