加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

Sqlserver 查询小技巧

发布时间:2020-12-12 14:08:36 所属栏目:MsSql教程 来源:网络整理
导读:--给列改名 方法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

--给列改名
方法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,sSex
from student

select distinct * from student

select distinct sName from student select distinct sName,sSex,sAge from student?? --distinct只有当所有的列都重复时,才会剔除

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读