关于查询语句

22233334444444 2019-06-03 11:38:17
这句话分开的话可以进行,合在一起就不行了,有什么好的办法吗?
select a.a/b.b from select sum(score) as a from 表1 where id in (select student_id from 表2 where class='"+banji+"') a,(select count(student_id) as b from 表2 where class='"+banji+"') b";
...全文
74 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
咸哼酒家 2019-06-04
  • 打赏
  • 举报
回复
表的别名a最好不要和字段别名一样,可能你只是想表达个替换的概念吧,第二个select前少了个括号

你只是想查询平均分吧,
select avg(表1.score)
from 表1, 表2
where 表1.class = 表2.class
and 表1.id = 表2.student_id
and class=''

51,408

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧