-- Sum () Numeric (data type) Function Description: sums all non-null values in a specified Column
-- AVG () Numeric (data type) Function Description: calculates the average value for all non-null values in the specified Column
-- Min () number, character, date (data type)
Function Description: returns the minimum number, minimum string, and earliest date and time in the specified column.
-- Max () number, character, date (data type)
Function Description: returns the maximum number, the maximum string, and the latest date in the specified column.
-- Count ([distinct] *) any row-based data type (data type)
Function Description: Total number of records and records in the statistical result set, up to 2147483647 rows
-- Count_big ([distinct] *) any row-based data type (data type)
Function Description: similar to the count () function. However, because the return value uses the bigint data type, a maximum of 2 ^ 63-1 rows can be displayed.
-- Note: 1. the distinct keyword can remove duplicate values from the column.
-- 2. The SELECT statement is used to query the statistical value without column names. You can use the newly generated column alias.
-- 3. Used with group by. Each aggregate function generates a value for each group.
-- 4. When the distinct keyword is specified together with the aggregate functions sum (), count (), and AVG (), duplicate values can be eliminated from the column. Format: Aggregate Function (distinct column name)
Use northwind
Select * from products
Select AVG (unitprice) as avuplice from products
Select categoryid, AVG (unitprice) from products group by categoryid
Select * from [Order Details]
Select orderid, sum (Quantity) productnumber from [Order Details] group by orderid
Select min (unitprice) from [Order Details]
Select productid, min (unitprice) from [Order Details] group by productid
Select max (unitprice) from [Order Details]
Select productid, max (unitprice) from [Order Details] group by productid
Select count (*) from [Order Details] Where orderid = 10248
Select count (orderid) from [Order Details]
Select count (distinct orderid) as ordernumber from [Order Details]