羅德興老師的教學歷程檔案 - 102-2 資訊技術 (資料庫進階應用) - 期末考加分題
 

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


歷程檔案 Portfolio

    期末考加分題

    期末考不理想的同學, 請在此留下你做錯的題目, 程式的意義與執行結果 (記得留學號, 註明卷別)


    資訊技術 (Database) 期中測驗 (A)   學號:      姓名:


    三個資料表 (Relation)與內容值如下, 其中,畫底線的欄位為主鍵,

    sporder中的sp_ssp_p分別是supplier2product的外來鍵


     

    supplier2

    s

    address

    1

    台北市

    2

    台中市

    3

    台南市

     

     

     

     

     

     

     

     

    product

    p

    cost

    10

    100

    20

    150

    30

    200

    40

    150

    50

    50

    60

    10

     

     

     

     

       sporder

    sp_s

    sp_p

    sp_qty

    10

    100

    20

    200

    30

    300

    20

    400

    30

    250

    10

    150

    40

    50

     


     

    1.     SELECT sp_s, sp_p, sp_qty AS 供應量 from sporder WHERE sp_s >'2';

    2.     SELECT sp_p,SUM(sp_qty) AS "供應量加總" FROM sporder GROUP BY sp_p ORDER BY sp_p;

    3.     SELECT sp_s,SUM(sp_qty*cost) AS Total FROM sporder sp JOIN product p ON sp.sp_p = p.p GROUP BY sp_s HAVING SUM(sp_qty*cost) > 120000 ORDER BY Total DESC;

    4.     Select * from product Where p NOT In (Select sp_p from sporder Where product.p = sporder.sp_p);

    5.     SELECT sporder.sp_s,SUM(sp_qty*cost) AS Total FROM sporder , product WHERE sporder.sp_p = product.p GROUP BY sporder.sp_s ORDER BY Total DESC;

    6.     SELECT sp_s, SUM (sp_qty*cost) FROM sporder LEFT JOIN product ON sporder.sp_p = product.p GROUP BY sp_s;

    7.     SELECT sp_s,  AVG (sp_qty) AS "平均值" FROM sporder LEFT JOIN product ON sporder.sp_p = product.p GROUP BY sp_s;

    8.     SELECT sp_s, MIN(sp_qty), MAX(sp_qty) FROM sporder LEFT JOIN product ON sporder.sp_p = product.p GROUP BY sp_s;

    9.     CREATE VIEW "供應總金額檢視表" AS SELECT sp_s, SUM (sp_qty*cost) FROM sporder LEFT JOIN product ON sporder.sp_p = product.p WHERE sp_s>= '2' GROUP BY sp_s;

    10.  SELECT COUNT(*) FROM supplier2;

     

     


     

    資訊技術 (Database) 期中測驗 (B)   學號:      姓名:


    三個資料表 (Relation)與內容值如下, 其中,畫底線的欄位為主鍵,

    sporder中的sp_ssp_p分別是supplier2product的外來鍵


     

    supplier2

    s

    address

    1

    高雄市

    2

    台中市

    3

    台北

     

     

     

     

     

     

     

     

    product

    p

    cost

    10

    10

    20

    50

    30

    150

    40

    200

    50

    100

    60

    300

     

     

     

     

       sporder

    sp_s

    sp_p

    sp_qty

    10

    50

    20

    150

    30

    250

    20

    400

    30

    300

    20

    200

    40

    50

     


    1.     SELECT sp_s, sp_p, sp_qty AS 供應量 from sporder WHERE sp_s >'2';

    2.     SELECT sp_p,SUM(sp_qty) AS "供應量加總" FROM sporder GROUP BY sp_p ORDER BY sp_p;

    3.     SELECT sp_s,SUM(sp_qty*cost) AS Total FROM sporder sp JOIN product p ON sp.sp_p = p.p GROUP BY sp_s HAVING SUM(sp_qty*cost) > 120000 ORDER BY Total DESC;

    4.     Select * from product Where p NOT In (Select sp_p from sporder Where product.p = sporder.sp_p);

    5.     SELECT sporder.sp_s,SUM(sp_qty*cost) AS Total FROM sporder , product WHERE sporder.sp_p = product.p GROUP BY sporder.sp_s ORDER BY Total DESC;

    6.     SELECT sp_s, SUM (sp_qty*cost) FROM sporder LEFT JOIN product ON sporder.sp_p = product.p GROUP BY sp_s;

    7.     SELECT sp_s,  AVG (sp_qty) AS "平均值" FROM sporder LEFT JOIN product ON sporder.sp_p = product.p GROUP BY sp_s;

    8.     SELECT sp_s, MIN(sp_qty), MAX(sp_qty) FROM sporder LEFT JOIN product ON sporder.sp_p = product.p GROUP BY sp_s;

    9.     CREATE VIEW "供應總金額檢視表" AS SELECT sp_s, SUM (sp_qty*cost) FROM sporder LEFT JOIN product ON sporder.sp_p = product.p WHERE sp_s>= '2' GROUP BY sp_s;

    10.  SELECT COUNT(*) FROM supplier2;

     

    全部共 0則留言
    登入帳號密碼代表遵守學術網路規範


    文章分類 Labels


    最新文章 Top10

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