如何在SQL表中获取金额的总和 [英] How to get the sum of amount in sql table

查看:285
本文介绍了如何在SQL表中获取金额的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下两个表

I am using two tables following

Temp
Billno  Item        Qty Rate amt Preferences
2       Icecream    2    10   20  Parcel
2       coffee      3     10   30  Parcel
1       Cream Salad  2     20   40  A/C
3        Cococola    5      15  60  Non A/C

Billing
Billno   Billamt
2           90
1           40
3           60


我想得到包裹的记录


I want get the records which is parcel

BillNo    Billamt
2           90

推荐答案

亲爱的,
你必须写
dear,
you have to write
select billno,item from table where preferences='Parcel'


尝试一下

Try this

select billno,SUM(amt)as Billamt from temp 
where preferences='Parcel'
group by billno


您好
试试这个
Hi
try this
SELECT distinct Temp.Billno
     ,Billamt
      ,[item]
  FROM Temp t inner join billing b on t.BillNo=b.BillNo where preferences='Parcel'



祝你好运



Best Luck


这篇关于如何在SQL表中获取金额的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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