统计多条记录多个字段的总和
发布网友
发布时间:2022-04-11 23:45
我来回答
共4个回答
懂视网
时间:2022-04-12 04:06
下面语句sql server与oracle均适用: select sum(A+B+C)AS Dfrom ...where ...group by ...
下面语句sql server与oracle均适用:
select sum(A+B+C)
AS D
from ...
where ...
group by ...
热心网友
时间:2022-04-12 01:14
SELECT *
FROM info a INNER JOIN
results b ON a.id= b.s_id
ORDER BY b.a1 + b.a2 desc
还有多个语文成绩?那用你的sql就可以
热心网友
时间:2022-04-12 02:32
写个通俗易懂的吧,同志哥:
如下:
select a.* from info a,Result b where a.id=b.S_ID order by (b.A1+b.A2) as hehe desc(或者asc)
热心网友
时间:2022-04-12 04:07
前面写错了,纠正一下.
select d.* from info d left join (select b.s_id,sum(b.a1) + sum(b.a2) as sums from info a,Results b where a.id = b.s_id group by b.s_id ) e on d.id = e.s_id order by e.sums desc