From 3600ef98e428888a73fcb82ee6c81a7fabea3e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=88=B4=E6=9C=A8=E3=80=80=E7=9A=93=E4=BB=8B?= <26-k-suzuki-avnz@it-college.co.jp> Date: Tue, 27 Oct 2026 17:23:38 +0900 Subject: [PATCH] =?UTF-8?q?Q2.2.3=20=E3=81=BE=E3=81=A7=E5=AE=8C=E4=BA=86?= =?UTF-8?q?=E6=B8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Answers/Question3_ongoing.txt | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Answers/Question3_ongoing.txt diff --git a/Answers/Question3_ongoing.txt b/Answers/Question3_ongoing.txt new file mode 100644 index 0000000..771eb69 --- /dev/null +++ b/Answers/Question3_ongoing.txt @@ -0,0 +1,41 @@ +--Q1 : Q3_DataDef.sql + +--Q2.1.1 +SELECT goods_m.goods_id AS '商品ID', + goods_m.goods_nm AS '商品名', + SUM(stock_m.arrival_num-stock_m.security_num) AS '在庫数' +FROM goods_m + INNER JOIN stock_m ON goods_m.goods_id = stock_m.goods_id +GROUP BY goods_m.goods_id; + +--Q2.1.2 +SELECT user_m.user_f_nm AS '氏', + user_m.user_nm AS '名', + user_m.user_birth AS '生年月日', + gender_m.gender_div_nm AS '性別', + credit_div_m.credit_div_nm AS 'クレジットカード分類名' +FROM user_m + INNER JOIN gender_m ON user_m.gender_cd = gender_m.gender_cd + LEFT JOIN credit_card_t ON user_m.user_id = credit_card_t.user_id + LEFT JOIN credit_div_m ON credit_card_t.credit_div_cd = credit_div_m.credit_div_cd; + +--Q2.1.3 +SELECT goods_m.goods_id AS '商品ID', + goods_m.goods_nm AS '商品名', + store_m.store_nm AS '入庫先倉庫名', + ins_stock_m.ins_stock_exp_date AS '入庫予定日' +FROM goods_m + INNER JOIN ins_stock_m ON goods_m.goods_id = ins_stock_m.goods_id + INNER JOIN store_m ON ins_stock_m.store_id = store_m.store_id +WHERE ins_stock_m.ins_stock_cmp_date IS NULL; + +--Q2.2.1+Q2.2.2 +INSERT INTO order_t(order_date, user_id, sts_cd, pay_div_cd, deli_company, tracing_no, arrive_exp_date) +VALUES ('2014/12/4', 'CU00000002', 'ST001', 'PY002', 'ヤマト', 'xxxxxxxxxxx', NULL); +SELECT * FROM order_t; + +--Q2.2.3 +INSERT INTO order_detail_t(order_no, goods_id, goods_unit_price, goods_num) +VALUES (5, 'ITM0000002', (SELECT goods_m.goods_price FROM goods_m WHERE goods_m.goods_id = 'ITM0000002'), 100); +INSERT INTO order_detail_t(order_no, goods_id, goods_unit_price, goods_num) +VALUES (5, 'ITM0000005', (SELECT goods_m.goods_price FROM goods_m WHERE goods_m.goods_id = 'ITM0000005'), 90);