sql查询分数大于60的人名和班级!!!

table1(name,sex,age)

table2(name,score subject)
table3(class,name)

select name,class from table1 t1,table2 t2,table3 t3 
where t1.name=t2.name and t1.name=t3.name and score subject>60

追问

我没办法试,希望是对的吧 我以为链接2个表就可以,原来是3个表。。。

追答select t1.name,t3.class from table1 t1,table2 t2,table3 t3 
where t1.name=t2.name and t1.name=t3.name and score subject>60

如果你给的题目没错的话没问题,有问题再追问吧,望采纳。

追问

嗯 可以在问一个吗?就是 查询出总分相同的班级 跪求!

追答

select t1.name,t3.class from table1 t1,table2 t2,table3 t3
where t1.name=t2.name and t1.name=t3.name and score subject>60

总分相同班级
select t1.class,t1.grade
from (select class,sum(grade) gd from table2 t1,table t3 where t2.name=t3.name group by class)t1,(select class,sum(grade) gd from table2 t1,table t3 where t2.name=t3.name group by class)t2 where t1.gd=t2.gd
t1.classt2.class and t1.gd=t2.gd
如果你给的题目没错的话没问题,有问题再追问吧,望采纳。

温馨提示:答案为网友推荐,仅供参考