본문 바로가기

728x90

SQL/[HackerRank]

[HackerRank/MySQL] Print Prime Numbers 소수만 출력하기 링크: https://www.hackerrank.com/challenges/print-prime-numbers/problem Print Prime Numbers | HackerRank Print prime numbers. www.hackerrank.com WITH RECURSIVE CT_COUNT AS (SELECT 2 AS P UNION ALL SELECT A.P+1 FROM CT_COUNT A WHERE A.P < 1000) SELECT GROUP_CONCAT(P SEPARATOR '&') FROM CT_COUNT A WHERE NOT EXISTS (SELECT 1 FROM CT_COUNT B WHERE A.P % B.P = 0 AND A.P !=.. 더보기
[HackerRank/MySQL] Draw The Triangle 2 삼각형 그리기 링크: https://www.hackerrank.com/challenges/draw-the-triangle-2/problem Draw The Triangle 2 | HackerRank Draw the triangle pattern using asterisks. www.hackerrank.com SET @n = 0; SELECT REPEAT('* ', @n := @n + 1) FROM information_schema.tables LIMIT 20 SET @a=b: 변수a를 선언하고 값b를 할당. SELECT: 키워드와 함께 검색하고 싶은 속성의 이름을 나열 REPEAT(문자열, n): 문자열을 n번 반복해 출력함. F.. 더보기
[HackerRank/MySQL] Draw The Triangle 1 삼각형 그리기 링크: https://www.hackerrank.com/challenges/draw-the-triangle-1/problem Draw The Triangle 1 | HackerRank Draw the triangle pattern using asterisks. www.hackerrank.com SET @number = 21; SELECT REPEAT('* ', @number := @number - 1) FROM information_schema.tables LIMIT 20 SET @a=b: 변수a를 선언하고 값b를 할당. SELECT: 키워드와 함께 검색하고 싶은 속성의 이름을 나열 REPEAT(문자열, n): 문자.. 더보기
[HackerRank/MySQL] 15 Days of Learning SQL 날짜마다 제출한 해커의 수와 가장 많이 제출한 hacker_id, 이름 구하기 링크: https://www.hackerrank.com/challenges/15-days-of-learning-sql/problem 15 Days of Learning SQL | HackerRank find users who submitted a query every day. www.hackerrank.com SELECT SUBMISSION_DATE, (SELECT COUNT(DISTINCT HACKER_ID) FROM SUBMISSIONS S2 WHERE S2.SUBMISSION_DATE = S1.SUBMISSION_DATE AND (SELECT COUNT(DISTINCT S3.SUBMI.. 더보기
[HackerRank/MySQL] Interviews contest_id, hacker_id, name, total_submissions의 합, total_accepted_submissions의 합, total_views의 합, total_unique_views의 합 구하기 (contest_id를 기준으로 오름차순 정렬) 링크: https://www.hackerrank.com/challenges/interviews/problem Interviews | HackerRank find total number of view, total number of unique views, total number of submissions and total number of accepted submissions. www.hackerrank.com < Co.. 더보기
[HackerRank/MySQL] Symmetric Pairs 짝 찾아주기 (x값 기준 오름차순) 조건 1. X1 = Y2 and X2 = Y1. 조건 2. X1 ≤ Y1 링크: https://www.hackerrank.com/challenges/symmetric-pairs/problem Symmetric Pairs | HackerRank Write a query to output all symmetric pairs in ascending order by the value of X. www.hackerrank.com SELECT f1.x, f1.y FROM functions f1 JOIN functions f2 ON f1.x = f2.y AND f1.y = f2.x GROUP BY f1.x, f1.y HAVING COUNT(f1.. 더보기
[HackerRank/MySQL] Placements 친구가 자신보다 더 높은 급여를 제안받은 학생의 이름 출력하기 (급여기준 오름차순) 링크: https://www.hackerrank.com/challenges/placements/problem 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 SELECT s.name FROM students s JOIN friends f ON s.id = f.id JOIN packages p1 ON s.id = p1.id JOIN packages p2 ON f.f.. 더보기
[HackerRank/MySQL] SQL Project Planning 프로젝트 별 시작일과 종료일 출력하기 (프로젝트 기간 기준 오름차순) 링크: https://www.hackerrank.com/challenges/sql-projects/problem 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 SELECT MIN(start_date), MAX(end_date) FROM (SELECT start_date, end_date, start_da.. 더보기

728x90