简单的查询语句2

USE demo
go
select * from text

--【1】在查询中使用常量列 :方便统计 增加列名年级,统一内容初一
select id 用户号, age 年龄,sex 性别,'初一' AS 年级 from text

--【2】查询返回限制的行数。使用top关键字
--(1)返回限定个数 限定出现两条数据,均为女生
select top 2 name AS 名字,age AS 年龄 from text where sex='女'
--(2)返回限定百分比20% PERCENT
select top 50 PERCENT name AS 名字,age AS 年龄 from text where sex='女'

posted @ 2018-08-14 23:27  生命不止追求不断  阅读(100)  评论(0编辑  收藏  举报