羅德興老師的教學歷程檔案 - 102-2 資訊技術 (資料庫進階應用) - 期中考練習作業上傳
 

企業資訊與管理系
助理教授/日導
羅德興


歷程檔案 Portfolio

    期中考練習作業上傳

    期中考練習作業
    1-10題, 每位同學分配做  (學號後三碼 mod 10) + 1
    請標明學號與題號,完成下列各題後上傳 


    資訊技術 (Database) 期中測驗 (AB)


    A.      以您的學號為名稱 (db********)建立一個資料庫 (5%)

    B.      建立三個資料表 (Relation)與內容值如下 (15%)

    其中,畫底線的欄位為主鍵,其值不能為空;

    sp_order中的sp分別是customeritem的外來鍵


     

    customer

    s_id

    s_addr

    1

    北市研究院路

    2

    宜蘭中正路1

    3

    基隆市

     

     

     

     

     

     

    Item

    p_id

    p_cost

    P01

    100

    P02

    250

    P03

    350

    P04

    400

     

     

     

     

     

       sp_order

    s

    p

    qty

    1

    P01

    200

    1

    P02

    300

    1

    P03

    300

    2

    P04

    400

    2

    P03

    500

    3

    P01

    1000

     


    1.      列出 sp 資料表中s (以客戶做為別名)pqty (以供應量做為別名),產生到一張新的資料表tempa

    2.      列出sp_order 客戶之訂貨總金額加總 (p 之訂貨量qty * item中的成本p_cost)大於15,000者之客戶。
    3.
    列出 sp 資料表中,各p (產品編號)之訂貨量 (qty)加總。
    4.
      按客戶 由小到大排序,列出 sp_order 資料表中所有資料列。
    5.
    下列SQL可完成什麼?

            SELECT O.s_id, sum(O.qty*P.p_cost) AS Total3 FROM sp_order O, item P

            WHERE O.p=P.p_id

            GROUP BY O.s

            ORDER BY Total3 DESC;

    6. 下列SQL可完成什麼?

            SELECT O.s, sum(O.qty*P.p_cost) AS Total2 FROM sp_order O, item P

            WHERE O.p=P.p_id

            GROUP BY O.s

            ORDER BY Total2;

    7. 列出item 資料表中,已被訂購者的p_id (產品編號)p_cost (單價)
    8. 列出有訂購P03 號產品者(p=P03)s s_addr (住址)
    9.
      列出訂購總金額加總為前三名者的s,p,qty,p_cost,與訂購總金額加總。
    10.
    列出 有訂購產品 客戶編號大於2的客戶與其地址。

    全部共 42則留言
    04-16 17:04:9914D134陳孟函 列出sp_order 客戶之訂貨總金額加總,由Tatal3大到小排序 Total query runtime: 11 ms. 3 rows retrieved.
    04-16 17:08:9914D154 蔡笠汝 列出客戶編號(S)的訂購總金額並由大到小排列:Total query runtime: 10 ms. 3 rows retrieved.
    04-17 11:15:9914D130 楊羚 列出 sp 資料表中s (以客戶做為別名)、p、qty (以供應量做為別名),產生到一張新的資料表tempa。 SELECT s AS 客戶,p ,qty AS 供應量 INTO tempa FROM sp_order SELECT * FROM tempa
    04-19 19:56:9914D117陳志瑋 SELECT * FROM customer WHERE s_id IN (SELECT p FROM sp_order WHERE p IN (SELECT p FROM sp_order WHERE p = '03'))
    04-19 19:56:9914D117陳志瑋 SELECT * FROM customer WHERE s_id IN (SELECT p FROM sp_order WHERE p IN (SELECT p FROM sp_order WHERE p = '03'))
    04-22 16:13:9914D156詹璽璋 Select * from ltem
    04-22 16:14:9914D147呂承庭 SELECT * FROM customer WHERE s_id IN (SELECT p FROM sp_order WHERE p IN (SELECT p FROM sp_order WHERE p = '03'))
    04-22 16:16:9914D159李棋幃 SELECT * FROM customer WHERE customer.s_id IN (SELECT sp_order.s FROM sp_order where s_id > '2' )
    04-22 16:30:留言...
    04-22 16:32:留言 ...
    04-23 00:24:9914D132 初源峻 SELECT p,SUM(qty) FROM sp_order GROUP BY p;
    04-23 12:49:9914D133 謝承霖 Select * from sp_order DESC;
    04-23 13:20:SELECT s as 客戶, p,qty as 供應量 from sp_order
    04-23 13:23:9914d120
    04-23 13:40:9914D128 田鈞帆 列出 sp 資料表中,各p (產品編號)之訂貨量 (qty)加總。 select * from sp_order ORDER BY s
    04-23 14:18:9914D116王紹銘 Select * from ltem
    04-23 14:19:9914D139 王玉如 SELECT * FROM customer WHERE customer.s_id IN(SELECT sp_order.s FROM sp_order LIMIT 2)
    04-23 14:20:9914D113 王韋傑 Select * from sp_order DESC;
    04-23 14:20:SELECT s,SUM(qty*p_cost) AS Total FROM sp_order JOIN item ON sp_order.p =item.p_id GROUP BY s HAVING SUM(qty*p_cost)>15000 ORDER BY Total DESC
    04-23 14:25:9914D157 楊亦紋 Select * From customer Where customer.s_id in (select sp_order.s From sp_order Limit 2)
    04-23 14:27:9914D146 劉璧菡 SELECT * FROM item Where p_id in (SELECT p from sp_order Where item.p_id = sp_order.p);
    04-23 14:29:9914D160 陳杰豪 列出 sp 資料表中s (以客戶做為別名)、p、qty (以供應量做為別名),產生到一張新的資料表tempa。 SELECT s AS 客戶,p ,qty AS 供應量 INTO tempa FROM sp_order SELECT * FROM tempa
    04-23 14:36:9914D153 黃巧婷 SELECT * FROM customer ORDER BY s_id ASC
    04-23 14:39:留言~
    04-23 14:43:9914D162 陳盈蓁 SELECT p,SUM(qty) FROM sp_order GROUP BY p;
    04-23 14:48:9914D137 梁茜琳 Select * From customer Where customer.s_id in (select sp_order.s From sp_order Limit 2)
    04-23 14:51:9914d136鄭羽涵 SELECT * FROM item Where p_id in (SELECT p from sp_order Where item.p_id = sp_order.p);
    04-23 14:58:留言...
    04-23 15:04:9914d140 蘇育晴 列出 sp 資料表中s (以客戶做為別名)、p、qty (以供應量做為別名),產生到一張新的資料表tempa。 SELECT s AS 客戶,p ,qty AS 供應量 INTO tempa FROM sp_order SELECT * FROM tempa
    04-23 15:11:9914D125 林瑋倫每位顧客訂購商品之總金額由小排到大 3 100000 2 195000 1 200000
    04-23 15:15:SELECT p,SUM(qty) FROM sp_order GROUP BY p; 9914D112蘇建霖
    04-23 15:19:SELECT s,SUM(qty*p_cost) AS Total FROM sp_order JOIN item ON sp_order.p =item.p_id GROUP BY s HAVING SUM(qty*p_cost)>15000 ORDER BY Total DESC 9914D111 陳坤宏
    04-23 15:32:留言...
    04-23 15:40:9914D124 吳程偉 列出sp_order 客戶之訂貨總金額加總,由Tatal3大到小排序 Total query runtime: 11 ms. 3 rows retrieved.
    04-23 15:41:9914D128 田鈞帆 第9題 SELECT s,p,qty,p_cost,qty*p_cost AS Total FROM sp_order JOIN item ON sp_order.p = item.p_id ORDER BY Total DESC LIMIT 3;
    04-23 16:18:9914D115 許登翔 select * from sp_order ORDER BY s
    04-23 16:19:9914D155 王振銘 每位顧客訂購商品之總金額由小排到大 3 100000 2 195000 1 200000
    04-23 16:22:SELECT sp_order.s,SUM(sp_order.qty*item.p_cost) AS Total FROM sp_order JOIN item ON sp_order.p = item.p_id GROUP BY sp_order.s HAVING SUM(qty*item.p_cost) > 15000 ORDER BY Total DESC;
    04-23 16:27:SELECT sp_order.s,SUM(sp_order.qty*item.p_cost) AS Total FROM sp_order JOIN item ON sp_order.p = item.p_id GROUP BY sp_order.s HAVING SUM(qty*item.p_cost) > 15000 ORDER BY Total DESC;
    04-23 16:36:SELECT sp_order.s,SUM(sp_order.qty*item.p_cost) AS Total FROM sp_order JOIN item ON sp_order.p = item.p_id GROUP BY sp_order.s HAVING SUM(qty*item.p_cost) > 15000 ORDER BY Total DESC;
    04-23 16:36:SELECT sp_order.s,SUM(sp_order.qty*item.p_cost) AS Total FROM sp_order JOIN item ON sp_order.p = item.p_id GROUP BY sp_order.s HAVING SUM(qty*item.p_cost) > 15000 ORDER BY Total DESC;
    05-21 15:42:SELECT p,SUM(qty) FROM sp_order GROUP BY p;
    登入帳號密碼代表遵守學術網路規範


    文章分類 Labels


    最新文章 Top10

    中華科技大學數位化學習歷程 - 意見反應