Sql中发生的问题 [英] Problem Occured in Sql

查看:69
本文介绍了Sql中发生的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表具有以下字段和记录

Billno金额
1200
1200
2 300
2 300

我想获得不同金额的总和(Billno),在此示例中,我的要求是500,但我不知道该怎么做,请有人帮忙解决这个问题

在此先感谢

My table has following fields and records

Billno Amount
1 200
1 200
2 300
2 300

i want to get sum of Amount in distinct(Billno),In this example My required answer is 500, but I didn''t know how to do it,Please somebody help for this proble

Thanks in Advance

推荐答案

这里是一种解决方案:

Here is one solution :

select SUM(amount) sum from(
select distinct billno, amount from bill) as distincted



希望对您有所帮助.



Hope it helps.


从表名中选择总和(不同金额)
SELECT SUM (DISTINCT Amount) FROM tablename


尝试一下!

Try this up!

SELECT SUM(Amount) FROM (SELECT DISTINCT BillNo FROM [TableName]



问候,
爱德华



Regards,
Eduard


这篇关于Sql中发生的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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