목록프로그래머스/SQL (9)
now is better than never
SELECT date_format(start_date, '%m') month , car_id , count(*) RECORDS FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY WHERE car_id in (select car_id from CAR_RENTAL_COMPANY_RENTAL_HISTORY where START_DATE between '2022-08-01' and '2022-10-31' group by car_id having count(*)>=5) AND START_DATE between '2022-08-01' and '2022-10-31' GROUP BY month, car_id HAVING records > 0 ORDER BY month asc, car_id desc ..
https://school.programmers.co.kr/learn/courses/30/lessons/151141 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr -- 코드를 입력하세요 SELECT history.HISTORY_ID, ROUND(car.DAILY_FEE * (100 - IFNULL(discount.DISCOUNT_RATE, 0))/100 * history.days) FEE FROM (SELECT * FROM CAR_RENTAL_COMPANY_CAR WHERE CAR_TYPE = '트럭') car JOIN (SELECT CAR_ID, HIS..
https://school.programmers.co.kr/learn/courses/30/lessons/157339 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr select c.car_id, c.car_type , round(c.daily_fee * (1 - d.discount_rate/100) * 30) fee from CAR_RENTAL_COMPANY_CAR c join CAR_RENTAL_COMPANY_DISCOUNT_PLAN d on c.car_type = d.car_type join CAR_RENTAL_COMPANY_RENTAL_HISTORY ..
https://school.programmers.co.kr/learn/courses/30/lessons/157342 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr SELECT car_id , round(avg(DATEDIFF(end_date, start_date)+1), 1) AVERAGE_DURATION FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY group by car_id having average_duration >= 7 order by 2 desc, 1 desc - 가 아니라 date 함수 써야 됨! 날짜 관련 함수 1...

https://school.programmers.co.kr/learn/courses/30/lessons/131118?language=oracle with score as (select inf.rest_id, round(avg(rev.review_score), 2) score from rest_info inf join rest_review rev on inf.rest_id = rev.rest_id group by inf.rest_id) SELECT inf.rest_id, inf.rest_name, inf.food_type , inf.favorites, inf.address , to_char(s.score, '999.99') score from rest_info inf join score s on inf.r..
MySQL SELECT member_id, member_name, gender , date_format(date_of_birth, '%Y-%m-%d') date_of_birth from member_profile where month(date_of_birth) = 3 and gender = 'W' and tlno is not null order by member_id Oracle SELECT member_id, member_name, gender , to_char(date_of_birth, 'YYYY-MM-DD') date_of_birth from member_profile where extract(month from date_of_birth) = 3 and gender = 'W' and tlno is ..