본문 바로가기

데이터/SQL 문제풀이29

프로그래머스(programmers) - LV. 5 상품을 구매한 회원 비율 구하기 프로그래머스는 hackerrank보다 전반적으로 쉽다고 하여, LV. 5부터 역순으로 풀어보려고 했다. 건드려 보니 안풀어봐도 될 것 같다는 생각이 들었다. Problem 다음은 어느 의류 쇼핑몰에 가입한 회원 정보를 담은 USER_INFO 테이블과 온라인 상품 판매 정보를 담은 ONLINE_SALE 테이블 입니다. USER_INFO 테이블은 아래와 같은 구조로 되어있으며 USER_ID, GENDER, AGE, JOINED는 각각 회원 ID, 성별, 나이, 가입일을 나타냅니다. Column name Type Nullable USER_ID INTEGER FALSE GENDER TINYINT(1) TRUE AGE INTERGER TRUE JOINED DATE FALSE GENDER 컬럼은 비어있거나 0 또는.. 2023. 7. 23.
HackerRank SQL - Binary Tree Nodes You are given a table, BST, containing two columns: N and P, where N represents the value of a node in Binary Tree, and P is the parent of N. Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node: Root: If node is root node. Leaf: If node is leaf node. Inner: If node is neither root nor leaf node. Sample Input Sample Output.. 2023. 7. 21.
HackerRank SQL - Weather Observation Station 20 A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to 4 decimal places. Input Format The STATION table is described as follows: where LAT_N is the northern latitude and LONG_W is the western longitude. Problem median(중위값)은 상위, 하위 절반을 구분한다. LAT_N의 중위값을 쿼리하라. Answer1 SET.. 2023. 2. 24.
HackerRank SQL - 15 Days of Learning SQL Julia conducted a days of learning SQL contest. The start date of the contest was March 01, 2016 and the end date was March 15, 2016. Write a query to print total number of unique hackers who made at least submission each day (starting on the first day of the contest), and find the hacker_id and name of the hacker who made maximum number of submissions each day. If more than one such hacker has .. 2023. 2. 22.
HackerRank SQL - Print Prime Numbers Write a query to print all prime numbers less than or equal to 1000 . Print your result on a single line, and use the ampersand (&) character as your separator (instead of a space). For example, the output for all prime numbers would be: 2&3&5&7 Problem 1~1000 중 소수를 출력하되, &문자로 구분하여 하나의 행으로 출력하라. Answer1 WITH RECURSIVE numbers AS ( SELECT 2 AS n UNION ALL SELECT 1+n FROM numbers WHERE n 1 AND n2.n 2023. 2. 21.
HackerRank SQL - Interviews Samantha interviews many candidates from different colleges using coding challenges and contests. Write a query to print the contest_id, hacker_id, name, and the sums of total_submissions, total_accepted_submissions, total_views, and total_unique_views for each contest sorted by contest_id. Exclude the contest from the result if all four sums are . Note: A specific contest can be used to screen .. 2023. 2. 13.
HackerRank SQL - Symmetric Pairs You are given a table, Functions, containing two columns: X and Y. Two pairs (X1, Y1) and (X2, Y2) are said to be symmetric pairs if X1 = Y2 and X2 = Y1. Write a query to output all such symmetric pairs in ascending order by the value of X. List the rows such that X1 ≤ Y1. Problem - 각각의 짝을 출력하는 쿼리를 작성하라. - 단, X의 값을 기준으로 내림차순, X=2 OR F.X < F.Y ORDER BY F.X 이것도 풀고나면 쉬운 문제였는데 상당히 헤매었던 문제다. 처음부터 셀프 .. 2023. 2. 12.
HackerRank SQL - Placements You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID (ID of the ONLY best friend). Packages contains two columns: ID and Salary (offered salary in $ thousands per month). Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be order.. 2023. 2. 5.