Results 1 to 3 of 3

Thread: Sum Query

  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: Sum Query

    I am trying to create a query that will give me a total amount per account. In this table that I have to work on, will have one account number that is duplicated all throught the table but it will be one customer. The customers payment history resides in this table, what they want is for the customers total amount they have paid for the year to show up in a report. So I need to create a report with that shows one record per customer/account number with the total amount that customer paid. So that way the report will show they customers their number and what they paid for the year. I am having such a hard time with this, theres no relationship within the database.

    Can anyone help me please??

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select account
         , sum(amount) as total_amount
      from daTable
    group
        by account
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    heres what I got

    Heres the select statement I go

    Code:
    SELECT     dbo.Employee_Fines.[TM #], SUM(dbo.FinePayments_Tbl.FinePayment) AS [Fine Payment], MIN(dbo.FinePayments_Tbl.DateOfPayment) 
                          AS [Date of Payment], MIN(dbo.FinePayments_Tbl.FineAmount) AS Amount
    FROM         dbo.Employee_Fines FULL OUTER JOIN
                          dbo.FinePayments_Tbl ON dbo.Employee_Fines.[TM #] = dbo.FinePayments_Tbl.[TM #]
    GROUP BY dbo.Employee_Fines.[TM #]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •