SQL1-ch4 群組函數與聚總資料. 題號  80 題: 33 、 39  140 題: 10 、 59 、 95 、 110.

Slides:



Advertisements
Similar presentations
SQL1-ch7 集合運算 1. 題號  80 題: 50 、 55 、 62  140 題: 41 、 61 、
Advertisements

Installment 7 Tables With No Column Presented by rexmen 2001 資管所.林彥廷.
SQL1-ch2 限制和排序資料. 考古題題號  80 題: 27 、 51  140 題: 23 、 58 、 70.
SQL1-ch11 使用資料說明視觀表 (Data Dictionary) 管理物件. 題號  80 題: 6 、 64  140 題: 105.
1 生物計算期末作業 暨南大學資訊工程系 2003/05/13. 2 compare f1 f2  只比較兩個檔案 f1 與 f2 ,比完後將結果輸出。 compare directory  以兩兩比對的方式,比對一個目錄下所有檔案的相 似程度。  將相似度很高的檔案做成報表輸出,報表中至少要.
Introduction to Java Programming Lecture 13 Classes I OO Programming.
建立使用案例敘述 --Use Case Narrative
Mar. 14, :Vito ’ s family ★☆☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10014:Vito’s family 解題者:劉淑惠、侯沛彣 解題日期: 2006 年 3 月 9 日 題意: Vito.
“Rule” By OX. By Check CREATE TABLE 員工薪資 ( 編號 int IDENTITY PRIMARY KEY, 薪資 smallmoney, CHECK ( 薪資 > 0 AND 薪資
T-SQL 運算子介紹 11/29. 運算子的總類 指定運算子 算術運算子 比較運算子 邏輯運算子 位元運算子 字串連結運算子 單一運算元運算子.
如何將數字變成可用之資訊 現代化資料處理與應用概念. 如何將數字變成可用之資訊 人最容易接受的訊息是圖像化資訊。 在一堆數字中,要進行比較分析,一般會使用表格形 式計算與分析。 所以一般我們會將數字依關聯性, 轉換成表格計算與分析。 此表格一般稱試算表或稱表格。 再將結果轉換為圖表,進行比較與分析。
目的 「升學調查系統」,幫助某一學校調查並記錄 其歷屆畢業生報考研究所的情況、未來提供給 學弟妹作參考,以及學校推廣之相關工作。 功能需求 紀錄並追蹤歷屆畢業生升學的狀態 協助畢業生做升學輔導 未來提供學弟妹作查詢、參考 計算上榜率、前十大學校上榜率.
BY OX. 檢視表與資料表的差異性 查詢 (query) 檢視表 (View) 的紀錄,是經由查詢 (query) 而來,而檢 視表的資料來源可以是單一資料表或是多資料表,甚 至其他檢視表 但檢視表中的紀錄只存在資料表中.
: Boxes ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11003: Boxes 解題者:蔡欣燁 解題日期: 2007 年 3 月 19 日.
: Factstone Benchmark ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: : Factstone Benchmark 解題者:鐘緯駿 解題日期: 2006 年 06 月 06 日 題意: 假設 1960.
Graph V(G 1 )={0, 1, 2, 3, 4, 5, 6, 7, 8, 9} E(G 1 )={(0, 2), (0, 3), (1, 4), (2, 3), (2, 5), (2, 6), (3, 6), (3, 7), (4, 7), (5, 6), (5,
: OPENING DOORS ? 題組: Problem Set Archive with Online Judge 題號: 10606: OPENING DOORS 解題者:侯沛彣 解題日期: 2006 年 6 月 11 日 題意: - 某間學校有 N 個學生,每個學生都有自己的衣物櫃.
: Matrix Decompressing ★★★★☆ 題組: Contest Volumes with Online Judge 題號: 11082: Matrix Decompressing 解題者:蔡權昱、劉洙愷 解題日期: 2008 年 4 月 18 日 題意:假設有一矩陣 R*C,
JAVA 程式設計與資料結構 第十四章 Linked List. Introduction Linked List 的結構就是將物件排成一列, 有點像是 Array ,但是我們卻無法直接經 由 index 得到其中的物件 在 Linked List 中,每一個點我們稱之為 node ,第一個 node.
溫丹瑋 10/29/2004 No. 7 查詢 溫丹瑋 10/29/2004.
Introduction to Java Programming Lecture 5: Using Java Classes : String & Math Spring 2009.
Introduction to pointers in C/C++. Pointers 特殊變數 存放變數在記憶體中的位址 MinGW C++ 中佔用 4 bytes 間接定址取執法 位址 指標變數 變數內容 變數.
: Walking on a Grid ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10913: Walking on a Grid 解題者:陳盈村 解題日期: 2008 年 5 月 2 日 題意:給定一個 N*N 矩陣,題目要求依照.
Chapter 13 塑模靜態觀點:物件圖 Static View : Object Diagram.
: Abundance and Perfect Numbers ★★★★☆ 題組: Contest Volumes with Online Judge 題號: 10914: Abundance and Perfect Numbers 解題者:劉洙愷 解題日期: 2008 年 5 月 2.
: Tight words ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: : Tight Words 解題者:鐘緯駿、林一帆 解題日期: 2006 年 03 月 14 日 題意: 給定數字 k 與 n (0 ≦ k.
Hung-Hsiang WuWindows Processing Design1 Chapter 3 基本觀念 變數宣告與型態 特殊運算子符號 字串與數值的轉換 類別與物件的觀念 建立新的專案 WinMain 程式進入點 Include Header File.
: Happy Number ★ ? 題組: Problem Set Archive with Online Judge 題號: 10591: Happy Number 解題者:陳瀅文 解題日期: 2006 年 6 月 6 日 題意:判斷一個正整數 N 是否為 Happy Number.
1 Netlibrary 電子書 Netlibrary 創始於 1998 年,是世界知名的電子書資 料庫,提供 450 多家出版社所出版近 100,962 ( 止)本的電子書,且以每月 2,000 本的 速度增加中。其中 80% 屬於學術性圖書,其餘 20% 一般圖書, 90% 以上為.
選舉制度、政府結構與政 黨體系 Cox (1997) Electoral institutions, cleavage strucuters, and the number of parties.
各種線上電子資源的特異功能 SwetsWise 的 alert, TOC alert 與 Favorites 2003/4/28 修改.
: Playing War ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11061: Playing War 解題者:陳盈村 解題日期: 2008 年 3 月 14 日 題意:在此遊戲中,有一類玩家一旦開始攻擊, 就會不停攻擊同一對手,直到全滅對方或無法再.
: Problem A : MiniMice ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11411: Problem A : MiniMice 解題者:李重儀 解題日期: 2008 年 9 月 3 日 題意:簡單的說,題目中每一隻老鼠有一個編號.
: Count DePrimes ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11408: Count DePrimes 解題者:李育賢 解題日期: 2008 年 9 月 2 日 題意: 題目會給你二個數字 a,b( 2 ≦ a ≦ 5,000,000,a.
1 Excel 講授內容 ( 進階 ) 授課教師 : 吳槐桂 最後更新 : 2008/05/01.
: Robot Motion ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: : Robot Motion 解題者:鄭昀旻 解題日期: 2009 年 5 月 20 日 題意:有一機器人會從網格的上(N)方進入, 依網格上之E、W、S、N之指令來行走,題目.
:Nuts for nuts..Nuts for nuts.. ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10944:Nuts for nuts.. 解題者:楊家豪 解題日期: 2006 年 2 月 題意: 給定兩個正整數 x,y.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
Management Abstracts Retrieval System; MARS 檢索操作.
: A-Sequence ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10930: A-Sequence 解題者:陳盈村 解題日期: 2008 年 5 月 30 日 題意: A-Sequence 需符合以下的條件, 1 ≤ a.
Section 4.2 Probability Models 機率模式. 由實驗看機率 實驗前先列出所有可能的實驗結果。 – 擲銅板:正面或反面。 – 擲骰子: 1~6 點。 – 擲骰子兩顆: (1,1),(1,2),(1,3),… 等 36 種。 決定每一個可能的實驗結果發生機率。 – 實驗後所有的實驗結果整理得到。
期末實機操作. 1. 新增屬性 當一個資料庫新建立之後,並未新增任何資料 至此資料庫之前,倘若要更改其中的檔案配置, 當然可以直接將此資料庫刪除後重建;不過, 在此資料庫建立並運作一陣子之後,裏面已經 儲存了很多不可被刪除的資料,那就必須使用 ALTER DATABASE 的方式來更改此資料庫的.
: GCD - Extreme II ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11426: GCD - Extreme II 解題者:蔡宗翰 解題日期: 2008 年 9 月 19 日 題意: 最多 20,000 組測資,題目會給一個數字.
JAVA 程式設計與資料結構 第二十章 Searching. Sequential Searching Sequential Searching 是最簡單的一種搜尋法,此演 算法可應用在 Array 或是 Linked List 此等資料結構。 Sequential Searching 的 worst-case.
資料結構實習-二.
: Expect the Expected ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11427: Expect the Expected 解題者:李重儀 解題日期: 2008 年 9 月 21 日 題意:玩一種遊戲 (a game.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Chapter 10 m-way 搜尋樹與B-Tree
Extreme Discrete Summation ★★★★☆ 題組: Contest Archive with Online Judge 題號: Extreme Discrete Summation 解題者:蔡宗翰 解題日期: 2008 年 10 月 13 日.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
SQL 進階查詢.
:Commandos ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11463: Commandos 解題者:李重儀 解題日期: 2008 年 8 月 11 日 題意: 題目會給你一個敵營區內總共的建築物數,以及建築物 之間可以互通的路有哪些,並給你起點的建築物和終點.
函式 Function 東海大學物理系‧資訊教育 施奇廷. 函式簡介 當程式越來越大、越複雜時,程式的維護、 除錯會變得更困難,此時必須引入函式來 簡化程式或將程式分段,將程式重複的部 分改寫為函式,將程式「模組化」 這種作法有下列優點:節省程式發展的時 間、邏輯容易瞭解、程式容易除錯、可分 工合作完成程式.
Visual C++重點複習.
資料結構實習-六.
電子書 ( Netlibrary ) 檢索說明 龍華科技大學圖書館. 檢索類型 檢索欄位與限制 在檢索中使用布林邏輯運算元 檢索結果 特殊檢索.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2010.
: SAM I AM ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11419: SAM I AM 解題者:李重儀 解題日期: 2008 年 9 月 11 日 題意: 簡單的說,就是一個長方形的廟裡面有敵人,然 後可以橫的方向開砲或縱向開砲,每次開砲可以.
C 語言練習題 2010/12/2. C 程式的格式 一、 C 程式的格式 (1). /* …. */ 是 C 程式的 ______ main() 的內容是由敘述構成的 (2). 敘述要以 __ 為結束符號 (3). 變數、函數都要做 ____ 的宣告 (4). ‘=’ 是 ____ 用的算符 (5).
: GCD (I) ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11424: GCD(I) 解題者:李育賢 解題日期: 2008 年 9 月 19 日 題意: 最多 20,000 組測資,題目會給一個數字 N(1
實體關係模型 (ER Model).
:Problem E.Stone Game ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10165: Problem E.Stone Game 解題者:李濟宇 解題日期: 2006 年 3 月 26 日 題意: Jack 與 Jim.
VHDL語法(3).
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
SQL1-ch5 顯示多個表格的資料. 題號  80 題: 34 、 57 、 71 、 72  140 題: 18 、 25 、 62 、 97 、 115 、 131.
SQL1-ch10 其他綱要物件. 題號  80 題: 5 、 9 、 18 、 32 、 38 、 41 、 44 、 54 、 77  140 題: 76 、 78 、 120 、 132.
SQL1-ch1 使用SQL SELECT 敘述句擷取資料.
SQL1-ch3 使用單列函數自訂輸出. 考古題題號  80 題: 7 、 37  140 題: 30 、 43 、 52 、 84 、 86 、 127.
SQL2-ch4 群組相關資料以產生報表. 題號  80 題: 11 、 20 、 43 、 59 、 70 、 80  140 題: 14 、 88 、 113.
SQL1-ch9 使用 DDL 建立與管理表格 1. 題號  80 題: 63 、 76  140 題: 6 、 24 、 44 、 71 、 77 、 92 2.
Presentation transcript:

SQL1-ch4 群組函數與聚總資料

題號  80 題: 33 、 39  140 題: 10 、 59 、 95 、 110

群組函數  群組函數 (group function)  聚總函數 (aggregate function)  每一組資料列只會有一個結果

練習  找出員工資料表中,最資深、資淺員工的 聘用日期。

群組函數  群組函數與空值

Q39/80( 可略 ) View the Exhibit and examine the description of the PRODUCT_INFORMATION table. Which SQL statement would retrieve from the table the number of products having LIST_PRICE as NULL? 6

A. SELECT COUNT(list_price) FROM product_information WHERE list_price IS NULL; B. SELECT COUNT(list_price) FROM product_information WHERE list_price = NULL; C. SELECT COUNT(NVL(list_price, 0)) FROM product_information WHERE list_price IS NULL; D. SELECT COUNT(DISTINCT list_price) FROM product_information WHERE list_price IS NULL; the number of products having LIST_PRICE as NULL? 7

資料群組  建立資料群組

Q33/80 Evaluate the following SQL statements: Statement 1: SELECT MAX(unit_price*quantity) “Maximum Order” FROM order_items; Statement 2: SELECT MAX(unit_price*quantity) “Maximum Order” FROM order_items GROUP BY order_id; Which statements are true regarding the output of these SQL statements? (Choose all that apply.) 9

A. Statement 1 would return only one row of output. B. Both the statements would give the same output. C. Statement 2 would return multiple rows of output. D. Statement 1 would not return any row because the GROUP BY clause is missing. E. Both statements would ignore NULL values for the UNIT_PRICE and QUANTITY columns. 10 SELECT MAX(unit_price*quantity) “Maximum Order” FROM order_items; SELECT MAX(unit_price*quantity) “Maximum Order” FROM order_items GROUP BY order_id;

資料群組  Group by  必須放在 where 子句之後  須包含欄位名稱或運算式  不可用欄位別名  可搭配單列函數使用  Select 子句中沒有使用聚總函數的欄位,須 使用 Group by 分群。

資料群組  依多個欄位分組

練習  找出每個部門中,最資深、資淺員工的聘 用日期。

Q110/140 Which two statements are true regarding the GROUP BY clause in a SQL statement? (Choose two.) A. You can use column alias in the GROUP BY clause. B. Using the WHERE clause after the GROUP BY clause excludes the rows after creating groups. C. The GROUP BY clause is mandatory( 強制的 ) if you are using an aggregate function in the SELECT clause. D. Using the WHERE clause before the GROUP BY clause excludes the rows before creating groups. E. If the SELECT clause has an aggregate function, then those individual columns without an aggregate function in the SELECT clause should be included in the GROUP BY clause. (P4-17)

群組篩選  不能在 where 中使用群組函數

群組篩選  群組條件的篩選,須使用 Having 子句

Q95/140 Which three statements are true regarding group functions( 群組函數 )? (Choose three.) A. They can be used on columns or expressions. B. They can be passed as an argument to another group function. C. They can be used only with a SQL statement that has the GROUP BY clause. D. They can be used on only one column in the SELECT clause of a SQL statement. E. They can be used along with the single-row function in the SELECT clause of a SQL statement. (P4-10)

Q10/140 Which three statements are true regarding the WHERE and HAVING clauses in a SQL statement? (Choose three.) A. The HAVING clause conditions can have aggregate functions. B. The HAVING clause conditions can use aliases for the columns. C. WHERE and HAVING clauses cannot be used together in a SQL statement. D. The WHERE clause is used to exclude rows before the grouping of data. E. The HAVING clause is used to exclude one or more aggregated results after grouping data.

Q59/140( 可略 ) View the Exhibit and examine the description of the PRODUCT_INFORMATION table. Which SQL statement would retrieve from the table the number of products having LIST_PRICE as NULL? A. SELECT COUNT(list_price) FROM product_information WHERE list_price IS NULL; B. SELECT COUNT(list_price) FROM product_information WHERE list_price = NULL;

C. SELECT COUNT(NVL(list_price, 0)) FROM product_information WHERE list_price IS NULL; D. SELECT COUNT(DISTINCT list_price) FROM product_information WHERE list_price IS NULL;