|
|
Archives of the TeradataForum
Message Posted: Wed, 10 Mar 2004 @ 13:57:07 GMT
Subj: | | Re: SQL for a Weekly Summary? |
|
From: | | de Wet, Johannes M |
Manish,
Actually, thinking about it a little more - you don't need the second join to the System Calendar at all. Try this.
SELECT
sc.week_of_calendar
,min(sc.calendar_date) AS Week_Begin_Date
,max(sc.calendar_date) AS Week_End_Date
,sum(a.check_gross_amt)
FROM
clmdb.claim_payment a
JOIN
sys_calendar.calendar sc
ON
a.payment_date = sc.calendar_date
GROUP BY 1
ORDER BY 2 DESC
Johannes de Wet
UnumProvident
| |