汇总数据
-
聚集函数
AVG()()返回某列平均值
COUNT() 返回某列的行数
MAX() 返回某列的最大值
MIN(() 返回某列的最小值
SUM()返回某列值之和
AVG()函数
SELECT AVG(prod_price) AS avg_price FROM Products;
COUNT()函数
SELECT COUNT(*) as num_cust FROM Customers;
MAX()函数
SELECT MAX(prod_price) AS max_price FROM products;
MIN()函数
SELECT MIN(prod_price) AS min_price FROM Products;
SUM()函数
SELECT SUM(quantity) AS items_ordered FROM OrderItems WHERE Order_num = 20005;
无欲则刚 关心则乱