지난 포스팅에서 Ui를 제작하였다.
이에 이어서 프로그램 실행에 필요한 쿼리를 만들기로 계획.
아래는 만든 쿼리들이다.
//기능1번쿼리 (지정구간 날짜 매출)
select a.transaction_date,SUM(REVENUE) from (select transaction_date,revenue from cafe_sales_report where TRANSACTION_DATE between TO_DATE('2023-01-01','YYYY-MM-DD') AND TO_DATE('2023-01-02','YYYY-MM-DD'))A group by A.TRANSACTION_DATE;
//기능2번쿼리 (지점별 각 메뉴의 매출)
select CASE WHEN row_number() over(partition by store_location order by product_category) = 1 then store_location else ' ' END AS store_location,product_category,count(*) from cafe_sales_report group by rollup(store_location,product_category) ;
//기능3번쿼리 (모든날짜 지점별 매출)
select transaction_date,store_location,sum(revenue) as revenue from cafe_sales_report group by transaction_date,store_location order by transaction_date,store_location;
/* 3번쿼리 검증 */
select transaction_date,store_location,sum(revenue) from cafe_sales_report where transaction_date = '2023-01-01' group by transaction_date,store_location order by 3 desc;
//기능4번쿼리 (데이터 수정)
update cafe_sales_report set A=B where transaction_id= C ; // A=수정 할 속성 B= 수정할 값 C=기본키
각 기능을 수행할 쿼리를 만들면서 검증도 함께 진행하였다.
쿼리를 만들면서 CASE - WHEN - END 조건문과 over(), partition by를 적용
프로그램 실행계획을 구체화 시킬 대략적 시나리오 작성
이로써 쿼리 제작을 마친다.
'Projects' 카테고리의 다른 글
[매출 관리 프로그램 제작] - 기능구현(3),시각화기능 추가 (0) | 2024.08.22 |
---|---|
[매출 관리 프로그램 제작] - 기능구현(2) (0) | 2024.08.20 |
[매출 관리 프로그램 제작] - 기능구현(1) (0) | 2024.08.18 |
[매출 관리 프로그램 제작] - Ui 구성단계 (0) | 2024.08.14 |
[매출 관리 프로그램 제작] - 환경 세팅 (0) | 2024.08.13 |