Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date into quarters

Status
Not open for further replies.

sparklewoman

Programmer
Apr 16, 2003
2
US
I have to create a sales report using current quarter totals and previous quarter totals. What is a simple of way breaking down the months in quarters and query on a sum for example invested amount?
 
In a report, you can do it in an After group of clause. It might look something like this.

After group of bill_paid

let sum1 = (total of invested) where
date >= '01/01/2003' and date <= '03/31/2003'
print sum1
let sum2 = (total of invested) where
date >= '04/01/2003' and date <= '07/31/2003'
print sum2
....


A couple of notes

whatever you use for your field in the after group of clause, must be in the order by of the select statement.

Also sum1, sum2,..., must be defined as a variable at the top of the report.

define
variable sum1 decimal(6,2)
variable sum2 decimal(6,2)
...
...
end

Dodge20
 
The sum is performed in a cursor before the printing on the report
here is an example:

PREPARE p_sum2 FROM
&quot;SELECT SUM(receivable) FROM temp_open1 \
WHERE branch = ? AND repnum = ? \
AND MONTH(selectdate) = MONTH(TODAY) - 1 \
AND YEAR(selectdate) = ? &quot;
DECLARE sum_recev2 CURSOR FOR p_sum2


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top