SQL 查询问题,请帮个忙

来源:百度知道 编辑:UC知道 时间:2024/06/24 11:34:15
表明:stu

表字段及数据类型

stuID(int),stuName(varchar),stuSubject(varchar),stuScore(int)
1001,'张三','C++',79
1001,'张三','JAVA',56
1002,'李四','SQL',67
1003,'王五','SQL',99
1003,'王五','JAVA',39
1004,'刘六','数学',58
1004,'刘六','C++',79
1004,'刘六','JAVA',67

我想查询JAVA成绩在60~70之间的学生信息(包括编号,姓名),、

请高手帮忙
用 SQL SERVER 语言来回复吧

PS: 按照你们告诉的方法去试一下了,但是查询结果有2行同样的数据,这是怎么回事?

select stuid,stuname from stu where stusubject='java' and stuscore between 60 and 70

select distinct stuid,stuname from stu where stusubject='java' and stuscore between 60 and 70

根据你给的记录,自己都可以看出应该是没有重复数据的,但既然出现了,你可以加distinct消除重复行试试

SELECT stuID,stuName
FROM stu
WHERE stuSubject='JAVA' AND stuScore BETWEEN 60 AND 70;

Select stuid,stuname from stu where stusubject='java' and stuscore >=60 and stuscore<=70

set field to stuID,stuName
browse for stuSubject="JAVA" and stuScore between 60 and 70