sql quary计算总和? [英] sql quary for calculate sum?

查看:90
本文介绍了sql quary计算总和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

专家,

我的桌子是这样的,桌子的名字很多.

hi experts,

my table was like this, table name exmple.

shiftno     sno     Amount

  100         7       20
              8       50
  101         9       10
              10      30
              11      20



我尝试过这个夸克
从示例中选择SUM(Amount),其中shiftNo =(从示例中选择(max(shiftNo))
它的鞋子reselt = 10,但最终结果是10 + 30 + 20 = 60.属于101号班次的
我怎样才能得到60的总结果?

可以请教...
在此先感谢...



i tried with this quary
select SUM(Amount) from exmple where shiftNo=(select (max(shiftNo)) from exmple
it shoes reselt=10,but auctual result is 10+30+20=60. which was belongs to shift no 101
how can i get total result of 60?

could you please advice...
thanks in advance...

推荐答案

根据我的理解,问题尚不清楚
您想要获取最大shiftno的金额总和

Question is not clear, as per my understanding
you want to get the sum of amount for max shiftno

select sum(amount) from <your table name> where shiftno=(select max(shiftno) from <your table name>



这对您有帮助

谢谢,
SP



This will help you

Thanks,
SP


SELECT SUM(AMOUNT) FROM MyTable WHERE ShiftNo = (SELECT MAX(ShiftNo) FROM MyTable)


尝试:
SELECT SUM(Amount) as AmountSum
FROM MyTable
WHERE (ShiftNo = (SELECT MAX(ShiftNo)FROM MyTable))


这篇关于sql quary计算总和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆