1.
select sno,sname from s where sedpt='cs' and sex='男';
2.
select avg(g) as avgg from sc where cno=(select cno from c where cname='数据库原理');
SQL语句的意思:
查询 s 表中 s中sdept字段不包含在后面这一结果 (查询s表中sno等于1001的值,返回sdept的结果集)的sno,sname的结果集。
简单地说,返回了所有sno不等于1001的sno,sname的结果集
大致的写了一下,没检查对错...感觉上条件给的不全,你们的sqlserver作业本意应该是要考察做联合查询的吧?把要求的条件写全了。
1. 查询计算机系(cs)的男生的学号、姓名
select sno,sname from s where sdept = cs and sex = 1
2. 查询数据库原理的平均成绩
select avg(g) as g from sc where cno in ( select * from c where cname = '数据库原理')
写出下面SQL语句的意思:
3. Select sno,sname from s where s.sdept not in (select sdept from s where sno=’1001’)
查询出与sno1001不在同一个系的学生sno,sname
select sno,sname from s where sdept="cs" and sex="男"
select avg(g) from sc where sc.cno in (select cno from c where cname="数据库原理")
查询与1001学号的学生不在一个系的学生学号和姓名
1. SELECT sno, sname from s where s.sex='男'
2. SELECT Avg(g) AS avgg FROM sc
意思:
查询系名不是'1001'的所有学生学号和姓名.
SELECT AVG(数据库原理) FROM sc