본문 바로가기

Algorithm/MySQL

(75)
[프로그래머스] 고양이와 개는 몇 마리 있을까 (MySQL) 문제 ANIMAL_INS 테이블은 동물 보호소에 들어온 동물의 정보를 담은 테이블입니다. ANIMAL_INS 테이블 구조는 다음과 같으며, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE는 각각 동물의 아이디, 생물 종, 보호 시작일, 보호 시작 시 상태, 이름, 성별 및 중성화 여부를 나타냅니다. ANIMAL_ID VARCHAR(N) FALSE ANIMAL_TYPE VARCHAR(N) FALSE DATETIME DATETIME FALSE INTAKE_CONDITION VARCHAR(N) FALSE NAME VARCHAR(N) TRUE SEX_UPON_INTAKE VARCHAR(N) FALSE 동물 보호소에 들어온 동물 ..
[해커랭크(Hacker Rank)] Type of Triangle (MySQL) 문제 Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table: Equilateral: It's a triangle with 3sides of equal length. Isosceles: It's a triangle with 2sides of equal length. Scalene: It's a triangle with 3sides of differing lengths. Not A Triangle: The given values of A, B, and C do..
[해커랭크(Hacker Rank)] Top Earners (MySQL) 문제 We define an employee's total earnings to be their monthly salary * months worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings. Then print these values as space-separated integers. 코드 SELECT * FR..
[해커랭크(Hacker Rank)] Weather Observation Station 4 (MySQL) 문제 Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table. The STATION table is described as follows: where LAT_N is the northern latitude and LONG_W is the western longitude. 코드 SELECT COUNT(city) - COUNT(DISTINCT(city)) FROM station 풀이 전체 city에서 중복되지 않는 city값 빼기 = 중복되는 city 수 city의 총 개수를 세고 city 이름들을 중복하지 않게 세서 차이를 보고 싶다 출처