CtronX (cyclotron) wrote in mysql,
CtronX
cyclotron
mysql

The sum total of a column

I thought this would be straight forward but I am having no luck with my query

SELECT SUM(Amount) AS total 
FROM office
WHERE datepaid BETWEEN '$range1' AND '$range2'


I have several rows of data and one column that I want to create a summary for by month. For this I am looping 12 times and storing the data in an array.

However, my result is incorrect. If I go line by line and total up the year I get a greater number. Is there something obviously wrong in my query?
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments