Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-09-24 : 08:16:15
|
Priya writes "I have to produce a report like this:Unemployemtn Rate report for a set of areas for current month, previous month of current year and current month of previous year.Unemployment Rate Sep 03 July 03 Sep 02---------------------------------------County A 3.2 3.1 3.6County B 3.4 3.3 3.6.... The table structure looks like 1. areacode, 2. year, 3.periodtype(annual, monthly), 4.period(Jan - 01, Feb - 02, Mar - 03..etc), 5. unemprateI started with writing a query to retrieve values for Sep 03 and Sep 02 only(One Self join). And it was easy. But to add the July 03 information was not that easy, meaning if current month is January 03, then I should be looking for Dec 02. Is it worth spending effort to write this query, or should I be heading over to Analysis Services? Or are there easier ways to retrieve such reports. ( We don't use any third party reporting tools)" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-09-24 : 13:38:22
|
| I do a very similar thing by using dynamic sql Start off with a tableyear, jandata, febdata, mardata, ...convert that to year, month, datathen tocurrentmonth, month-1, month-2, quarter-1, quarter-2, quarter-3, quarter-4which is what the users want.It all takes quite a long time==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|