일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- seaborn
- MySQL
- join
- PostgreSQL
- 파이썬
- Limit
- GROUPBY
- 그로스해킹
- SQLite
- Oracle
- 머신러닝
- 데이터분석
- 프로그래머스
- solvesql
- 다중 JOIN
- hackerrank
- pandas
- airflow.cfg
- Round
- airflow 설치
- 데이터리안 웨비나
- 전처리
- matplotlib
- SUM
- having
- not in
- 데이터시각화
- TRUNCATE
- SQL
- 결측값
Archives
- Today
- Total
Milky's note
[HackerRank](E) Draw The Triangle 2 본문
Draw The Triangle 2 | HackerRank
Draw the triangle pattern using asterisks.
www.hackerrank.com
[문제]
P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):
*
* *
* * *
* * * *
* * * * *
Write a query to print the pattern P(20).
[답]
- mysql
set @star=0;
select repeat('* ', @star := @star+1)
from information_schema.tables
limit 20;
이전문제와 반대되는 케이스이다.
처음에 1부터 시작해서 20개까지의 별을 찍는 문제이다.
마찬가지로 변수 설정을 위해 set를 사용해주었고 대입을 하기 위해 := 를 사용해서 변수를 대입해주었다.
이 문제는 라인이 추가될 수록 별의 갯수가 늘어나기 때문에 변수 := 변수 +1 에 대입해주었다.
'SQL > SQL 코딩 테스트-HackerRank' 카테고리의 다른 글
[HackerRank](M) Weather Observation Station 18 (0) | 2022.03.28 |
---|---|
[HackerRank](M) New Companies (0) | 2022.03.28 |
[HackerRank](E) Draw The Triangle 1 (0) | 2022.03.26 |
[HackerRank](M) The Report (0) | 2022.03.25 |
[HackerRank](E) Average Population of Each Continent (0) | 2022.03.25 |
Comments