select sname,avg(grade) from sc,student wherestudent.sno=sc.sno 这句话有没有错,求grade的平均值select sname,avg(grade) from sc,student wherestudent.sno=sc.sno这句话有没有错,求grade的平均值

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 14:47:27

select sname,avg(grade) from sc,student wherestudent.sno=sc.sno 这句话有没有错,求grade的平均值select sname,avg(grade) from sc,student wherestudent.sno=sc.sno这句话有没有错,求grade的平均值
select sname,avg(grade) from sc,student wherestudent.sno=sc.sno 这句话有没有错,求grade的平均值
select sname,avg(grade) from sc,student wherestudent.sno=sc.sno
这句话有没有错,求grade的平均值

select sname,avg(grade) from sc,student wherestudent.sno=sc.sno 这句话有没有错,求grade的平均值select sname,avg(grade) from sc,student wherestudent.sno=sc.sno这句话有没有错,求grade的平均值
SQL是一种结构化查询语言即Structure Query Language
一般格式:
SELECT[DISTINCT]<目标列表达式>…
FROM<表名>,<查询名>……
[WHERE <条件表达式>]
[GROUP BY<列名1>[HAVING<条件表达式>]
[ORDER BY<列名2>[ASC│DESC];
SELECT SNAME,SDEPT FROM STUDENT
SELECT SNO,CNO FROM 查询1
SELECT * FROM STUDENT
SELECT DISTINCT SNO FROM SC
SELECT SNAME,SAGE FROM STUDENT WHERE SDEPT='CS'
WHERE SAGE NOT BETWEEN 10 AND 18
'',"";
BETWEEN #1978-01-01# AND #1980-12-31#
*,?,#
'' ""
IN NOT IN
WHERE SDEPT IN('CS','IS'); SDEPT='CS' OR SEPT='IS'
LIKE *,?,#
SELECT * FROM STUDENT WHERE SNAME LIKE '刘?'
SAGE LIKE '1#'
1按学生成绩降序排序,成绩相同按课程号排序
select * from sc order by grade desc,cno
2安课程号排序,课程号相同按成绩将需排列
IS NULL,IS NOT NULL
SELECT SNO,CNO FROM SC WHERE GRADE IS NULL
count(*),count(CNO),sum(),avg(),min(),max()
select count(*) from sc
select cno,count(*) from sc group by cno
and or not
select sname ,2003-sage as 出生年份 from student
SELECT SC.SNO,SNAME,CNO FROM STUDENT,SC WHERE STUDENT.SNO=SC.SNO
SELECT C1.CNO,C2.CPNO FROM COURSE C1,COURSE C2 WHERE C1.CPNO=C2.CNO
LEFT JOIN RIGHT JOIN
SELECT course.*, sc.*
FROM course LEFT JOIN sc ON course.cno = sc.cno;
SELECT SNAME+SDEPT AS SNSD FROM STUDENT
1查询信息系年龄在18到20之间的学生信息
SELECT *
FROM STUDENT
WHERE SDEPT='IS'AND SAGE BETWEEN 18 AND 20;
2查询每门课程相应的选课人数
SELECT CNO,COUNT(SNO)
FROM SC
GROUP BY CNO;
SELECT COUNT(*) FROM SC
3查询每个学生不及格课程门数
SELECT CNO,COUNT(CNO)
FROM SC
WHERE GRADE<60
GROUP BY SNO
4查询成绩在90到100份之间的每门课程的选修人数
SELECT CNO, COUNT( SNO)
FROM SC
WHERE GRADE BETWEEN 90 AND 100
GROUP BY CNO ;
5查询姓名第二个字是“力”的学生姓名和所在系
SELECT SNAME,SDEPT
FROM STUDENT
WHERE SNAME LIKE "?力*";
6查询没有成绩的学生学号和对应的课程号
SELECT SNO,CNO
FROM SC
WHERE GRADE IS NULL;
7查询数学系和信息系所有男学生的情况
SELECT *
FROM STUDENT
WHERE SDEPT ="IS" OR SDEPT= "MA" AND SSEX="男";
8查询总成绩大于200分的学生学号
SELECT SNO
FROM SC
GROUP BY SNO HAVING SUM(GRADE)>200;
SELECT * FROM SC ORDER BY SNO ,GRADE DESC
1.SELECT ENO,ENAME FROM EMP,WORKS WHERE
CMP.ENO=WORKS.ENO,SEX='男',AGE>50
2.SELECT ENO,ENAME FROM EMP ,WORKS WHERE SALARY>1000 AND EMP.ENO=WORKS.ENO
3.SELECT ENO,ENAME FROM EMP,COMP,WORKS WHERE CNAME="LHGS" AND WORKS.CNO=COMP.CNO AND EMP.ENO=WORKS.ENO
4.SELECT ENO,ENAME FROM EMP,COMP,WORKS WHERE WORKS.CNO=COMP.CNO AND EMP.ENO=WORKS.ENO AND SEX='M'AND CNAME='LHGS' AND SALARY>1000
left join right jion
select * from student left join sc on studnt.sno=sc.sno
#1987-10-01#
1、select distinct sno from sc where grade<60
2 select * from student where sdept in('cs','is')
select * from student where sdept='cs' or sdept='is'
3 select sno,sname,sage from student where sage between 10 and 19
>=10 and <=19
like '1#'
4 select sname ,sdept from student where sname like '?力*'
5 select sno from sc where grade is not null
子查询
概念:
分类:
引导谓词:select from where sage>(select sage from student where sdept='cs')
>,=,<
查询和刘晨同在一个系学习的学生
SELECT S1.* FROM STUDENT S1,STUDENT S2 WHERE S2.SNAME='刘晨' AND S1.SDEPT=S2.SDEPT
SELECT *
FROM STUDENT
WHERE SDEPT=
(SELECT SDEPT
FROM STUDENT
WHERE SNAME='刘晨')
select sname from student where sdept=(select sdept from student where sname='刘晨')
in
查询选修了数据库课程的学生的姓名和所在系
SELECT SNAME,SDEPT
FROM STUDENT
WHERE SNO IN
( SELECT SNO
FROM SC
WHERE CNO IN
(SELECT CNO
FROM COURSE
WHERE CNAME='数据库'))
select sname ,sdept
from student
where sno in
(select sno
from sc
where cno=
(select cno
from course
where cname='数据库'))
select sname ,sdept
from student,sc,course
where student.sno=sc.sno and sc.cno=course.cno and cname='数据库'
查询其他系比信息系任一学生年龄小的学生情况
any,all
>any大于子查询结果中的某个值(>min()大于最小值)
>all大于子查询结果中的所有值(>max()大于最大值)
<any小于子查询结果中的某个值(<max()小于最大值)
<all小于子查询结果中的所有值(<min()小于最小值)
SELECT *
FROM STUDENT
WHERE SAGE<(SELECT max(SAGE)
FROM STUDENT WHERE SDEPT='IS')
AND SDEPT<>'IS'
select sname
from student
where sage <any(select sage from student where sdept='is') and sdept <>'is'
集合查询
并(UNION)、交、差
查询既选修了1号课程又选修了2号课程的学生学号.
SELECT SNO FROM SC WHERE CNO=1 AND SNO IN(SELECT SNO FROM SC WHERE CNO=2)
exists
网络班
查询选修了全部课程的学生姓名
select sname
from student
where sno in
(select sno
from sc
group by sno having count(*)=
(select count(*)
from course) )
使用EXISTS
SELECT SNAME
FROM STUDENT
WHERE NOT EXISTS
(SELECT *
FROM COURSE
WHERE NOT EXISTS
(SELECT *
FROM SC
WHERE SNO=STUDENT.SNO
AND CNO=COURSE.CNO))
查询至少选修了01001选修的全部课程的学生号码
select sno from sc where cno in(select cno from sc where sno=01001) group by sno having count(*)=(select count(*) from sc where sno=01001)
SELECT SNAME FROM STUDENT
WHERE SNO IN(SELECT SNO FROM SC WHERE CNO IN(SELECT CNO FROM COURSE WHERE CNAME='数据库'))
更新查询
插入(INSERT INTO)
INSERT INTO STUDENT VALUES(95033,'','IS','男',19)
INSERT INTO C1(CPNO,CNAME)
SELECT CPNO,CNAME FROM COURSE WHERE CNO IN(1,2)
INSERT INTO SC1(SNO,CNO)
SELECT SNO,CNO FROM STUDENT,COURSE
修改(UPDATE)
UPDATE SC SET GRADE=0 WHERE 'IS'=(SELECT SDEPT FROM STUDENT WHERE SNO=SC.SNO )
删除(DELETE)
DELETE FROM C1
DELETE FROM SC WHERE 'IS' =(SELECT SDEPT FROM STUDENT WHERE SNO=SC.SNO)
UPDATE STUDENT SET SNO=95030 WHERE SNO=95004

select sname,avg(grade) from sc,student wherestudent.sno=sc.sno 这句话有没有错,求grade的平均值select sname,avg(grade) from sc,student wherestudent.sno=sc.sno这句话有没有错,求grade的平均值 avg. WHERE S.Sno=SC.Sno AND Cname!=数据结构GROUP BY Sname HAVING AVG(Grade)>80里面的S.Sno=SC.Sno 还有GROUP BY Sname HAVING AVG(Grade)>80 select.where student_id>3 GROUP BY math_mark having AVG(math_mark)>70什么意思啊?GROUP BY math_mark having AVG(math_mark)>70 主要是这一部分 if (pastart = -1) sql.append(select * from(); sql.append(select nid,sname,sdescription,nprice,sif (pastart = -1)sql.append(select * from();sql.append(select nid,sname,sdescription,nprice,simg,(CASE smctag WHEN '0' THEN '有货'WHEN '1' THEN ' sql语句:去掉最大值,去掉最小值,算平均值SELECT AVG(Scores.Score)FROM ScoresWHERE ( ( (Scores.[ID]) = @id)AND (Score < (SELECT MAX(Score) From Scores WHERE Scores.[ID] = @id) )AND (Score > (SELECT MIN(Score) From Scores WHERE Scores.[I 在关键字 'group' 附近有语法错误.select sname from s,scwhere s.sno = sc.snoand sc.grade = nullhaving count(*) >= 2group by sc.sno avg 是什么意思 AVG是什么意思 什么是GRA? GRA是什么意思 Gra 是什么意思? SELECT 查询语句中,共有三个部门:10,20,30,查询哪些雇员的工资高于所在部门的平均工资,请问三个命令的区别正确语句如下: SELECT deptno,ename,sal FROM emp outer WHERE sal>( SELECT avg(sal) 关于数据库Oracle的一道题a.course=b.能通俗点解析吗?select courseid as 课程ID,course as 课程名称,nvl(avg(grade),0) as 平均成绩,(select count(grade) from train a where grade Delphi 查询 Access 错误:Field 平均 not foundadoquery1.SQL.Clear;adoquery1.Close;adoquery1.sql.add('select avg(English) as 平均 from Subject');adoquery1.ExecSQL;edit1.Text := adoquery1.Fieldbyname('平均').AsStringadoquery1.sql.add('select MA (select * from student where sname like '王%') 我查出了姓王的,但那非 字 不知道怎么表示了.题目是查表 student中不是姓王的信息 select Student.Sno,Sname,Ssex,Cname,Grade from Student,SC,Course where Student.Sno=SC.Sno and SC.Cnoorder by Student.Sno 用sql server对上述结果做分页显示,我以前没学过对分页不了解,