distinct关键词专用于消除重复记录
SELECT DISTINCT COLUMN1, COLUMN2,....COLUMNN FROM TABLE_NAME WHERE [CONDITION];
--通过distinct关键字消除重复姓名 select * from staff; select DISTINCT SNAME FROM STAFF;
order by 子句专用于对一个活多个字段按升序或者降序排序
SELECT COLUMN-LIST
FROM TABLE_NAME
[WHERE CONDITION]
[ORDER BY COLUMN1,COLUMN2,COLUMN3...COLUMNN] [asc|desc]
select * from staff ORDER BY ssalary asc;
select * from staff ORDER BY ssalary desc;
group by 配合相同数据进行分组
select column-list
from table_name
where [conditions]
group by column1,column2
select *,SUM(ssalary) from staff GROUP BY Spost ORDER BY SNAME;
having子句专用于指定条件来过滤数据
Select * from table_name
where
group by
having
order By;
//统计 按职务分组统计 职务数量大于2个的组别 having 要跟在group by 后面
select *,sum(ssalary) from staff GROUP BY spost HAVING Count(spost) >2;
标签:group,Distinct,ssalary,having,Qrderby,QSLite,ORDER,select,staff From: https://www.cnblogs.com/baisedeyu/p/17900773.html