목록Oracle (19)
dearbeany
select a.category, b.max_price, a.product_name from FOOD_PRODUCT a, ( select category, max(price) as max_price from food_product where category in ('과자', '국', '김치', '식용유') group by category) b where a.category = b.category and a.price = b.max_price order by 2 desc;
select car_id, case when car_id in (select car_id from CAR_RENTAL_COMPANY_RENTAL_HISTORY where to_char(start_date, 'yyyy-mm-dd') = '2022-10-16') then '대여중' else '대여 가능' end as AVAILABILITY from CAR_RENTAL_COMPANY_RENTAL_HISTORY group by car_id order by car_id desc;
select car_type, count(car_id) as cars from (select * from car_rental_company_car where options like '%통풍시트%' or options like '%열선시트%' or options like '%가죽시트%') group by car_type order by car_type;
select category, sum(sales) as total_sales from (select a.book_id, a.category, b.sales_date, sales from book a, book_sales b where a.book_id = b.book_id and to_char(sales_date, 'yyyy-mm') = '2022-01' ) group by category order by category ;
select substr(price,1,1)*10000 as "price_group", count(*) as products from product group by substr(price,1,1)*10000 order by substr(price,1,1)*10000;
select name, count(name) as 'count' from animal_ins where name is not null group by name having count(*) >= 2 order by name;
select animal_type, count(*) as 'count' from animal_ins group by animal_type order by animal_type;