We help IT Professionals succeed at work.
Get Started

how to get sum of distinct records

211 Views
Last Modified: 2015-02-28
Hi experts
i have an SQL query that return a distinct records

select distinct VENDOR_NUMBER,VENDOR_NAME,CHECK_DATE,EMAIL_ADDRESS,FAX,check_amount
from MOF_AP_REMITTANCE_GFOS_HEADER_HISTORY
 where VENDOR_NUMBER = 4382501 and DATEPART(yy, CHECK_DATE) = '2015'

Open in new window


vno          vname   check_date    email               fax         check_amount
---------------------------------------------------------------------------------------------------
4382501      Zayani      2015-01-15       xx@bb.com      NULL      1460.000
4382501      Zayani      2015-01-29       xx@bb.com      NULL      5556.000
4382501      Zayani      2015-02-15       xx@bb.com      NULL      730.000
4382501      Zayani      2015-02-15       xx@bb.com      NULL      11781.000

i need to get the sum of each record if i have more than one record
i need the result to look like the following

vno          vname   check_date    email               fax         SUM check_amount
---------------------------------------------------------------------------------------------------
4382501      Zayani      2015-01-15       xx@bb.com      NULL      1460.000
4382501      Zayani      2015-01-29       xx@bb.com      NULL      5556.000
4382501      Zayani      2015-02-15       xx@bb.com      NULL      12511.000

any suggestion
Comment
Watch Question
EE Topic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2014
Awarded 2013
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE