NEW QUESTION - sum'ing filtered columns
All,
I previously asked about getting the sum of a columnin a db. I figured out to add an item to SELECT statement to create a variable:
txtSQL.CommandText = "SELECT customer_number, past_due_30, SUM(total_due) AS 'intTotalDue'" & _
"FROM accounts_receivable" & _
"WHERE past_due_30 > '0'" & _
"ORDER BY past_due_30 DESC ;"
But this appears to create a variable named intTotalDue that is the total of the entire column (total_due) from the database, not just the total of the column (total_due) in the recordset.. How do I total just the filtered record's column? Do I have to create a nested SELECT statement or can I use the HAVING clause - if so how?
thanks a lot,
Nick
|