1 / 6
文档名称:

MySQL.doc

格式:doc   页数:6页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

MySQL.doc

上传人:drp539604 2015/9/3 文件大小:0 KB

下载得到文件列表

MySQL.doc

文档介绍

文档介绍:12·汇总函数
'tomers;nt(*) as num_custe
函数
说明
AVG()
返回某列的平均值
MAX()
返回某列的最大值
COUNT()
返回某列的行数
SUM()
返回某列值之和
MIN()
返回某列的最小值
select avg(prod_price) as avg_price from products;
+-----------+
| avg_price |
+-----------+
| |
+-----------+
select avg(prod_price) as avg_price from products where vend_id = 1003;
+-----------+
| avg_price |
+-----------+
| |
+-----------+
COUNT(*)对表中行的数目进行计数,不管列中包含的是NULL值还是非NULL值。
COUNT(column)对特定列中具有值的行进行计数,忽略NULL值。
select count(*) as num_cust from customers;
+----------+
| num_cust |
+----------+
| 5 |
+----------+
select
vend_name, prod_name, prod_price
from
vendors,
products
where
=
order by vend_name , prod_name;
select
vend_name, prod_name, prod_price
from
vendors,
products
order by vend_name , prod_name;
select
vend_name, prod_name, prod_price
from
vendors
inner join
products ON = ;
select
prod_name, vend_name, prod_price, quantity
from
orderitems,
products,
vendors
where
=
and =
and order_num = 20005;
select
cust_name, cust_contact
from
customers
where
cust_id in (select
cust_id
from
orders
where
ord