- 0
- 0
- 约2.23千字
- 约 9页
- 2017-12-26 发布于河北
- 举报
SQL(三)
sql(3) Aggregate Functions Aggregate Functions Aggregate functions are used to compute against a returned column of numeric data from your SELECT statement. They basically summarize the results of a particular column of selected data. We are covering these here since they are required by the next topic, GROUP BY. Although they are required for the GROUP BY clause, these functions can be used without the GROUP BY clause. Aggregate Functions -----example: SELECT AVG(salary)FROM employee; This statement will return a single result which contains the average value of everything returned in the salary column from the employee table. Aggregate Functions -----example: SELECT AVG(salary)FROM employee;WHERE title = Programmer; This statement will return the average salary for all employees whose title is equal to Programmer Aggregate Functions -----Example: SELECT Count(*)FROM employees; This particular statement is slightly different from the other aggregate functions since there isnt a column supplied to the count function. This statement will return the number of rows in the employees table. Aggregate Functions---Review Exercises Select the maximum price of any item ordered in the items_ordered table. Hint: Select the maximum price only. Select the average price of all of the items ordered that were purchased in the month of Dec. Aggregate Functions---Review Exercises What are the total number of rows in the items_ordered table? For all of the tents that were ordered in the items_ordered table, what is the price of the lowest tent? Hint: Your query should return the price only. Aggregate Function Exercise Answers Exercise #1 SELECT max(price)FROM items_ordered; Exercise #2 SELECT avg(price)FROM items_orderedWHERE order_date LIKE %Dec%; Exercise #3 SELECT count(*) FROM items_ordered; Exercise #4 SELECT min(price) FROM items_ordered WHERE item = Tent; * * returns the number of rows in a table COUNT(*) returns the total number of values in
您可能关注的文档
- MATLAB 程序设计-04.ppt
- MATLAB 第5章 MATLAB符号运算-复习.ppt
- mazhe绪论.ppt
- MBA营销管理3消费者行为分析.ppt
- MBA培训教程:人力资源规划.ppt
- mcse第五课.ppt
- MD节能演示.ppt
- mfc张海林等编著Visual C++简明教程课件第1章.ppt
- MIS 第2节.ppt
- MoCA_Clink 技术简介.pptx
- 小区绿化施工协议书.docx
- 墙面施工协议书.docx
- 1 古诗二首(课件)--2025-2026学年统编版语文二年级下册.pptx
- (2026春新版)部编版八年级道德与法治下册《3.1《公民基本权利》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《4.3《依法履行义务》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.2《按劳分配为主体、多种分配方式并存》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.1《公有制为主体、多种所有制经济共同发展》PPT课件.pptx
- 初三教学管理交流发言稿.docx
- 小学生课外阅读总结.docx
- 餐饮门店夜经济运营的社会责任报告(夜间贡献)撰写流程试题库及答案.doc
原创力文档

文档评论(0)