selectt1fromawherea.t2in(selectu1fromb)anda.t3in(selectu1fromb)a.t4in(selectu1fromb)。
- 情感问答
- 答案列表
sql多表查询语句:sql语句多表查询案例[朗读]
--楼主我帮你写吧--有什么疑问可以随时找我希望采纳declare@idec(12,2)declare@jdec(12,2)select@i=scorefromaselect@j=sum(score)from(selectscorefrom?
其实多表查询,用到的关键字,就是像innerjoin,leftjoin,rightjoin之类的,根据具本情况,选择自已适合的连接语句.举个例子吧selecta.studnt_sno,b.sno,c.gradefromstudntasainnerjoindepartasbona.sno=b.snoleftjoinscasconb.cno=c.no。
1.selectcount(*)from成绩表where成绩<802.selectavg(成绩)from成绩表where课程号=数学课的课程号3.selectcount(*)from学生表groupby专业名4.selecttop3b。
给个思路数据略多不好模拟a表里面根据deptid和parentid生成一个二叉树select..fromastartwithdeptid=0001connectbypriordeptid=parentid;这个查询把所有的对应关系整出来然后leftjoinb表ona.deptid=b.deptid最后再做一下统计就可以弄出来。