💡 목표
SELECT b.title,
b.board_id,
r.reply_id,
r.writer_id,
r.contents,
LEFT(r.created_date, 10) AS created_date
FROM used_goods_board b
JOIN used_goods_reply r
ON b.board_id = r.board_id
WHERE LEFT(b.created_date,7) = "2022-10"
ORDER BY r.created_date, b.title
DATE_FORMAT(%Y-%m-%d)
를 활용해도 됨SELECT food_type,
rest_id,
rest_name,
MAX(favorites) AS favorites
FROM rest_info
GROUP BY food_type
ORDER BY food_type DESC
SELECT food_type,
rest_id,
rest_name,
favorites
FROM rest_info
WHERE (food_type, favorites) IN(
SELECT food_type,
MAX(favorites)
FROM rest_info
GROUP BY food_type)
ORDER BY food_type DESC
SELECT b.category, SUM(bs.sales) AS total_sales
FROM book b
JOIN book_sales bs
ON b.book_id = bs.book_id
WHERE LEFT(bs.sales_date, 7) = "2022-01"
GROUP BY b.category
ORDER BY b.category
SELECT MONTH(start_date) AS month, car_id, COUNT(car_id) AS 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
ORDER BY month, car_id DESC