Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- count
- Algorithm
- STR
- If
- join
- decorator
- js
- len
- FOR
- Python
- index
- iNT
- and
- slice
- or
- sum
- split
- enumerate
- list
- 위코드
- range
- MAX
- 파이썬
- Sorted
- LOWER
- lambda
- SQL
- map
- DART
- WECODE
Archives
- Today
- Total
코드로 우주평화
SQL Basics: Simple HAVING 본문
For this challenge you need to create a simple HAVING statement, you want to count how many people have the same age and return the groups with 10 or more people who have that age.
people table schema
- id
- name
- age
return table schema
- age
- total_people
Solution:
SELECT
age,
COUNT(age) AS total_people
FROM
people
GROUP BY
age
HAVING
COUNT(age) >= 10
Result:
age | total_people |
16 | 13 |
54 | 11 |
47 | 14 |
99 | 11 |
46 | 20 |
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
Sum of all the multiples of 3 or 5 (0) | 2022.07.20 |
---|---|
SQL Basics: Simple JOIN with COUNT (0) | 2022.07.19 |
Hello SQL World! (0) | 2022.07.17 |
GROCERY STORE: Logistic Optimisation (0) | 2022.07.16 |
SQL: Regex Replace (0) | 2022.07.15 |