[SQL] WHEN, DATE SELECT BOARD_ID, WRITER_ID, TITLE, PRICE, CASE WHEN STATUS = 'SALE' THEN '판매중' WHEN STATUS = 'DONE' THEN '거래완료' WHEN STATUS = 'RESERVED' THEN '예약중' END AS STATUS FROM USED_GOODS_BOARD WHERE DATE(CREATED_DATE) = '2022-10-05' ORDER BY BOARD_ID DESC; ㅋㅌ 2023.09.20
[SQL] 출력 순서 정렬 SELECT ANIMAL_TYPE, COUNT(ANIMAL_TYPE) AS "count" FROM ANIMAL_INS WHERE ANIMAL_TYPE IN ('Cat', 'Dog') GROUP BY ANIMAL_TYPE ORDER BY FIELD(ANIMAL_TYPE, 'Cat', 'Dog'); SELECT ANIMAL_TYPE, COUNT(ANIMAL_TYPE) AS "count" FROM ANIMAL_INS WHERE ANIMAL_TYPE IN ('Cat', 'Dog') GROUP BY ANIMAL_TYPE ORDER BY CASE ANIMAL_TYPE WHEN 'Cat' THEN 1 WHEN 'Dog' THEN 2 END; ㅋㅌ 2023.09.06