/*
执行顺序
1.where
2.GROUP BY
3.having
4.ORDER BY
*/
/*
where和having都是条件筛选,不过它们有区别
where是对表里原始的数据进行的筛选,一般最先执行
having是对表中数据分组使用聚合函数计算之后(经过加工)
的数据进行的筛选,having在where之后,having与GROUP BY配
合使用
*/
SELECT TOP 3 * FROM student
SELECT TOP 60 PERCENT * FROM student
SELECT * FROM student
/*
DISTINCT关键字是去掉重复值
*/
SELECT DISTINCT stuAddress AS '地址' FROM student
SELECT DISTINCT stuAddress '地址',stuAge AS 年龄 FROM student --相当于这2个字段都要满足重复值才会去重
select stuAddress,COUNT(distinct stuAddress) from student group by stuAddress