码迷,mamicode.com
首页 > 其他好文 > 详细

汇总函数

时间:2015-05-31 13:39:48      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

SELECT COUNT(ALL SALARY) FROM EMPLOYEE_PAY_TBL;
+-------------------+
| COUNT(ALL SALARY) |
+-------------------+
|                 3 |
+-------------------+

SELECT COUNT(SALARY) FROM EMPLOYEE_PAY_TBL;
+---------------+
| COUNT(SALARY) |
+---------------+
|             3 |
+---------------+


SELECT PAGER FROM EMPLOYEE_TBL;
+------------+
| PAGER      |
+------------+
| 3175709980 |
| NULL       |
| NULL       |
| 8887345678 |
| NULL       |
| NULL       |
+------------+

SELECT SUM(PAGER) FROM EMPLOYEE_TBL;
+-------------+
| SUM(PAGER)  |
+-------------+
| 12063055658 |
+-------------+

SELECT SUM(LAST_NAME) FROM EMPLOYEE_TBL;
+----------------+
| SUM(LAST_NAME) |
+----------------+
|              0 |
+----------------+


SELECT AVG(PAY_RATE), AVG(SALARY) FROM EMPLOYEE_PAY_TBL;
+---------------+--------------+
| AVG(PAY_RATE) | AVG(SALARY)  |
+---------------+--------------+
|     13.583333 | 30000.000000 |
+---------------+--------------+


SELECT PROD_DESC FROM PRODUCTS_TBL;
+-------------------------+
| PROD_DESC               |
+-------------------------+
| WITCH COSTUME           |
| ASSORTED MASKS          |
| FALSE PARAFFIN TEETH    |
| ASSORTED COSTUMES       |
| PLASTIC PUMPKIN 18 INCH |
| PUMPKIN CANDY           |
| PLASTIC SPIDERS         |
| CANDY CORN              |
| LIGHTED LANTERNS        |
+-------------------------+
SELECT MAX(PROD_DESC) FROM PRODUCTS_TBL;
+----------------+
| MAX(PROD_DESC) |
+----------------+
| WITCH COSTUME  |
+----------------+
SELECT MIN(PROD_DESC) FROM PRODUCTS_TBL;
+-------------------+
| MIN(PROD_DESC)    |
+-------------------+
| ASSORTED COSTUMES |
+-------------------+


SELECT * FROM ORDERS_TBL;
+---------+---------+---------+-----+------------+
| ORD_NUM | CUST_ID | PROD_ID | QTY | ORD_DATE   |
+---------+---------+---------+-----+------------+
| 16C17   | 090     | 222     |   2 | 2009-10-17 |
| 18D778  | 287     | 90      |  10 | 2009-10-17 |
| 23E934  | 432     | 13      |  20 | 2009-10-15 |
| 32A132  | 43      | 222     |  25 | 2009-10-10 |
| 56A901  | 232     | 11235   |   1 | 2009-10-22 |
| 56A917  | 12      | 907     | 100 | 2009-09-30 |
+---------+---------+---------+-----+------------+

SELECT COUNT(ORD_NUM), SUM(QTY), SUM(QTY) / COUNT(ORD_NUM), AVG(QTY) FROM ORDERS_TBL;
+----------------+----------+---------------------------+----------+
| COUNT(ORD_NUM) | SUM(QTY) | SUM(QTY) / COUNT(ORD_NUM) | AVG(QTY) |
+----------------+----------+---------------------------+----------+
|              6 |      158 |                   26.3333 |  26.3333 |
+----------------+----------+---------------------------+----------+

 

汇总函数

标签:

原文地址:http://www.cnblogs.com/fatoland/p/4541821.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!