[SQLPlus] Extracting dates per week

Associate
Joined
28 Nov 2002
Posts
766
Location
Down the road
We have a database which stores dates of transactions and other associated info.
I want to product a weekly summary for the last year, along the lines of:
Code:
Week			# Transactions
-------			---
Week1			40
Week2			86
...
Week 51			55
Week52			22

But don’t want to manually enter the date ranges because I’m too lazy!

Is there any more efficient way of getting the data out of the database?

Thanks for any tips!
 
If it was MSSQL, you can use the following;

Code:
SELECT 'Week ' +  LTRIM(STR(DATEPART(ww , [date]))) AS Week FROM[table]

Substituting [date] for your date field, etc.
 
DB2 SQL has a week() function which will give you a week number from a date or timestamp. Chances are there will be something similar in SQLPlus
 
Back
Top Bottom