sql面试遇到的一个问题. select *from tb awhere score>(select avg(score) score from tb where id=a.id) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 create table tb(id char(3),name nvarchar(20),score int);insert tb select '001' , ' 张' , 70 insert tb select '001' , '张' , 80 insert tb select '001' , '张' , 50 insert tb select '002' , '李' , 60 insert tb select '002' , '李' , 90 insert tb select '003' , '赵' , 100 insert tb select '003' , '赵' , 60 insert tb select '003' , '赵' , 70 select * from tb a where score> (select avg(score) score from tb where id=a.id)drop table tb/*id name score---- -------------------- -----------001 张 70001 张 80002 李 90003 赵 100(4 行受影响)*/ i like this:select a.* from tablename a join (select id,avg(score) score from tablename group by id) b on a.id=b.id and a.score>b.score 请问在XP下可以装SQL005吗?如果可以那装那个版本 求一SQL语句 寻求SQL语句注释? 根据传递的参数值来组合查询条件? 请问有哪些字符不能作为字符型字段的值? 无法连接远程数据库服务器 数据表某列统一在数据前面添加固定数字 谁有ERwin的使用方面的书籍或资料?谢谢! develop6i開發中的疑問? 大数据量表查询操作 耗时太长 求优化 关于网站数据库同步问题~~ 请教高手从哪里可以看数据库现在是否有人连接!在线等!!
insert tb select '001' , ' 张' , 70
insert tb select '001' , '张' , 80
insert tb select '001' , '张' , 50
insert tb select '002' , '李' , 60
insert tb select '002' , '李' , 90
insert tb select '003' , '赵' , 100
insert tb select '003' , '赵' , 60
insert tb select '003' , '赵' , 70 select *
from tb a
where score> (select avg(score) score from tb where id=a.id)drop table tb/*
id name score
---- -------------------- -----------
001 张 70
001 张 80
002 李 90
003 赵 100(4 行受影响)
*/
select a.* from tablename a join
(select id,avg(score) score from tablename group by id) b
on a.id=b.id and a.score>b.score