------使用distinct消除重复值----
use AdventureWorks
select distinct HireDate
from HumanResources.Employee
-----在聚合函数中使用distinct -----
-----如果你想计算产品列表的平均价格,可以使用如下查询语句----
select AVG(ListPrice) from Production.Product
-----使用列别名-----
select Color as 'Grouped Color',
AVG(DISTINCT ListPrice) as 'Average Distinct List Price',
AVG(ListPrice) 'Average List Price'
from Production.Product
group by Color
use AdventureWorks
-----对结果排序-----
select select_list
[INTO new_table_name]
from table_list
[WHERE search_conditions]
[GROUP BY group_by_list]
[HAVING search_conditions]
[ORDER by order_list [ASC | DESC]]
use AdventureWorks
select distinct HireDate
from HumanResources.Employee
-----在聚合函数中使用distinct -----
-----如果你想计算产品列表的平均价格,可以使用如下查询语句----
select AVG(ListPrice) from Production.Product
-----使用列别名-----
select Color as 'Grouped Color',
AVG(DISTINCT ListPrice) as 'Average Distinct List Price',
AVG(ListPrice) 'Average List Price'
from Production.Product
group by Color
use AdventureWorks
-----对结果排序-----
select select_list
[INTO new_table_name]
from table_list
[WHERE search_conditions]
[GROUP BY group_by_list]
[HAVING search_conditions]
[ORDER by order_list [ASC | DESC]]