Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 777.8k

SQL Query to find Sum of a column

May 12 2014 4:13 AM
I need your help to find a result of this query.
 
I need to get the total value of column highlighted  below as yellow .
 
I tried as (sum(A0519.nettamt) as SUM). but it is not working. Pls provide correct query.
 
select distinct a0519.billno,a0519.opno,a0519.patname,a0519.patage,a0519.agetypecd,
a0519.patsex,a0519.billdate,(a0052.fname + ' ' + ISNULL(a0052.Mname, '') + ' ' + ISNULL(a0052.Lname, '')) as fname,
a0519.nettamt,a0519.disctype,a0519.billtypecd, a0052.empcd,a0067.description,a0520.mstcd,a0067.mstcd,a0067.deptcd,a0009.deptname,a0520.itemvalue
from a0519
inner join a0052 on a0052.empcd=a0519.empcd
inner join a0520 on a0520.billno=a0519.billno and a0520.billtypecd=a0519.billtypecd
inner join a0067 on a0067.mstcd=a0520.mstcd
inner join a0009 on a0009.deptcd = a0067.deptcd
where UPPER(a0519.isactive) = 'Y' and UPPER(a0067.isactive)='Y' and UPPER(a0520.isactive)='Y'
And ((CAST(CONVERT(VARCHAR, a0519.BILLDATE, 106) AS DATETIME)) BETWEEN ('04-05-2013') AND ('04-05-2013')) and a0067.deptcd=180
order by a0067.description

Answers (2)