--给列改名
方法1.
select sName as '姓名',sAge as '年龄' from student
方法2.
select sName '姓名',sAge '年龄' from student
方法3.
select '姓名'=sName,'年龄'=sAge from student
--Top Distinct
select top 2 sName,sAge,sSex from student
order by sAge
--百分之10个学生 如果有小数位数,直接进1
select top 10 percent sName,sAge,sSex
from student
select distinct * from student
select distinct sName from student
select distinct sName,sSex,sAge from student --distinct只有当所有的列都重复时,才会剔除
本文介绍了SQL中给列重命名的方法及使用TOP DISTINCT进行数据筛选的技巧。通过三种不同的方式展示如何更改查询结果中的列名,并演示了如何选取特定数量的数据记录及去除重复项。
1200

被折叠的 条评论
为什么被折叠?



