본문 바로가기

데이터 분석/SQL 연습문제45

Placements (HackerRank) Placements | HackerRank Write a query to output the names of those students whose best friends got offered a higher salary than them. www.hackerrank.com Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be ordered by the salary amount offered to the best friends. It is guaranteed that no two students got same salary offer. 풀이.. 2023. 3. 28.
262. Trips and Users (LeetCode) Trips and Users - LeetCode Can you solve this real interview question? Trips and Users - Table: Trips +-------------+----------+ | Column Name | Type | +-------------+----------+ | id | int | | client_id | int | | driver_id | int | | city_id | int | | status | enum | | request_at | leetcode.com Write a SQL query to find the cancellation rate of requests with unbanned users (both client and drive.. 2023. 3. 27.
Weather Observation Station 20 (HackerRank) Weather Observation Station 20 | HackerRank Query the median of Northern Latitudes in STATION and round to 4 decimal places. www.hackerrank.com 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 decimal places. 풀이 제출한 답 with sub as ( select *, row_number() over (ord.. 2022. 11. 7.
Weather Observation Station 11 (HackerRank) Weather Observation Station 11 | HackerRank Query a list of CITY names not starting or ending with vowels. www.hackerrank.com Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates. 풀이 제출한 답 select distinct city from station where city not regexp '^[aeiou].*[aeiou]$' -> .은 어떤 문자든 일치, *은 문자를 여러 번 반복 2022. 11. 6.
Ollivander's Inventory (HackerRank) Ollivander's Inventory | HackerRank Help pick out Ron's new wand. www.hackerrank.com Hermione decides the best way to choose is by determining the minimum number of gold galleons needed to buy each non-evil wand of high power and age. Write a query to print the id, age, coins_needed, and power of the wands that Ron's interested in, sorted in order of descending power. If more than one wand has s.. 2022. 11. 5.
SQL Project Planning (HackerRank) SQL Project Planning | HackerRank Write a query to output the start and end dates of projects listed by the number of days it took to complete the project in ascending order. www.hackerrank.com Write a query to output the start and end dates of projects listed by the number of days it took to complete the project in ascending order. If there is more than one project that have the same number of .. 2022. 11. 4.
Binary Tree Nodes (HackerRank) Binary Tree Nodes | HackerRank Write a query to find the node type of BST ordered by the value of the node. www.hackerrank.com 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: 풀이 제출한 답 select N, (case when p is null then 'Root' when N in (select p from bst) then 'Inner' else 'Leaf' end) from bst order by N -> P에 있는 값이.. 2022. 11. 3.
Weather Observation Station 5 (HackerRank) Weather Observation Station 5 | HackerRank Write a query to print the shortest and longest length city name along with the length of the city names. www.hackerrank.com Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes .. 2022. 10. 12.
Occupations (HackerRank) Occupations | HackerRank Pivot the Occupation column so the Name of each person in OCCUPATIONS is displayed underneath their respective Occupation. www.hackerrank.com Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively. 풀이.. 2022. 10. 11.
New Companies (HackerRank) New Companies | HackerRank Find total number of employees. www.hackerrank.com Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code. 풀이 제출한 답 select c.company_code, c.founder, (select count(distinct Le.. 2022. 10. 5.