练习:20号
--取得当前系统时间
select getdate()
--从表中查询成绩及格的所有学生名单
select * from studentScore where stuScore >=60
--查询成绩在70-80之间的所有数据
select * from studentScore where stuScore between 70 and 80(where后面为列名)
--查询前三行
select top 3 * from studentScore
--查学习成绩在前三名的(即降序查询)
select top 3 * from studentScore order by stuScore desc
--查百分之二十的数据
select top 20 percent * from studentScore
--按升序排列查20%数据
select top 20 percent * from studentScore order by stuID asc(升序默认asc可省去)
--计算所有学生的总成绩
select sum (stuScore) from studentScore
--查平均分
select avg (stuScore) from studentScore
--查学生最高分
select max (stuScore) from studentScore
--查学生最低分
select min (stuScore)from studentScore
--查有多少学生(有多少行)
select count(*) from studentScore
--把学生成绩列转化成字符型数据
select convert(varchar(20),stuScore) from studentScore
阅读(600) | 评论(0) | 转发(0) |