导入成功之后,可以点开表格查看内容:
(如下图即导入成功)
其他表同理可得,也可以同时导入
SELECT * FROM student
SELECT sno,sname FROM student
SELECT sname,YEAR(GETDATE())-sageFROM student
SELECT sname 姓名,YEAR(GETDATE())-sage 出生年FROM student
select * FROM student WHERE sdept='CS'
select * FROM student WHERE sdept='CS' AND ssex='男'
(1)方法一
select * from student where sage>=18 and sage<=20
(2)方法二
select * from student where sage BETWEEN '18' AND '20'
(1)方法一
select * from student where sage<18 or sage>20
(2)方法二
select * from student where sage not BETWEEN '18' AND '20'
(1)方法一
select * from student where sdept='CS' or sdept='JD'
(2)方法二
select * from student where sdept in('CS','JD')
select * from student where sname like'张%'
select sno,sname from student WHERE sname LIKE '李_';
select * from sc WHERE grade IS NULL;
select DISTINCT sage FROM student WHERE sdept='cs'
select TOP 3 * from student
(1)方法一
select COUNT(sno) 男生人数 from student where ssex='男'
(2)方法二
select COUNT(*) AS 男生人数 from student where ssex='男'
select COUNT(distinct sno) from sc
select max(grade) 最高分,MIN(grade) 最低分 from sc
select SUM(grade) 总分,AVG(grade) 平均分 from sc where sno='1204304102'
select sname 姓名,YEAR(GETDATE())-sage as 出生年,院系=sdept from student
查询姓张的学生的信息
select * from student where sname like'张%'
查询姓黄的学生的信息(当姓氏后面只有一个字时)
select * from student where sname like'黄_'
查询名字中有“文”这个字的学生的信息
select * from student where sname like'_文_'
查询前三个同学的信息
select TOP 3 * from student
查询课程编号是‘2102’的课程分数降序排列
select grade from sc where cno='2102' order by grade desc
查询课程编号是‘2102’的课程分数降序排列的前两名
select TOP 2 grade from sc where cno='2102' order by grade desc
到此这篇关于SQL Server单表数据查询的文章就介绍到这了,更多相关SQLServer单表数据查询内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!