I am having trouble counting the TotalAmount incrementing by however many more number of policies there are iterating through each row.
For Example consider the following code:
SELECT Customer.custno, Customer.enteredDate AS 'Date Entered', COUNT(BasicPolInfo.polid) AS 'Number of Policies', SUM( COUNT(BasicPolInfo.polid)) over() AS TotalAmount FROM Customer INNER JOIN BasicPolInfo ON Customer.custid = BasicPolInfo.custid WHERE BasicPolInfo.polid IS NOT NULL and Customer.firstname IS NOT NULL AND Customer.enteredDate > '1/1/79' GROUP BY Customer.custno, Customer.firstname, Customer.lastname, Customer.entereddate ORDER BY Customer.enteredDate ASC What I would like to see is the TotalAmount Column be added from the Number of Policies iterating through each and every customer.
ex:
21 -- date -- 6 -- 6 24 -- date -- 13 -- 19 25 -- date -- 23 -- 32 29 -- date -- 16 -- 48 I could care less for the order of the custno, rather I am more concerned if the total policies are even 159703? There are more than 1000 rows in this SQL.
Please help me how I am able to sum each row from the preceding total sum!