본문 바로가기
데이터분석/TIL

240808 TIL

by Freely_ 2024. 8. 8.
728x90
반응형

Views 테이블

 

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.
The result format is in the following example.

 

자신의 기사 중 하나 이상 본 모든 저자를 찾아 ID별로 오름차순으로 반환

 

  • 풀이
SELECT distinct author_id id
FROM views
WHERE author_id = viewer_id
ORDER BY 1

Tweets 테이블

 

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.
The result format is in the following example.

 

유효하지 않는 트윗의 ID를 반환, 트윗 내용에 사용된 문자의 수가 15개보다 크면 트윗은 유효하지 않는다.

 

  • 풀이
SELECT tweet_id
FROM tweets
WHERE CHAR_LENGTH(content) > 15

 

문자열 길이 조회

LENGTH() CHAR_LENGTH()
문자열의 byte 길이 반환 문자열 길이 반환

Employees 테이블

 

EmployeeUNI 테이블

 

Write a solution to show the unique ID of each user, If a user does not have a unique ID replace just show null.
Return the result table in any order.
The result format is in the following example.

 

고유 ID를 가지고 있지 않은 사용자는 null로 대체하여 각 사용자의 고유 ID를 반환

 

  • 풀이
SELECT eu.unique_id, name
FROM employees e
LEFT JOIN employeeuni eu
ON e.id=eu.id
728x90
반응형

'데이터분석 > TIL' 카테고리의 다른 글

240814 TIL  (0) 2024.08.14
240807 TIL  (0) 2024.08.07
240806 TIL  (0) 2024.08.06