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 |
|
anuraag205
Yak Posting Veteran
58 Posts |
Posted - 2012-08-27 : 06:04:24
|
| i have a table containing years, months and sales as coloumns. I want to add a new coloum which specifies the name of quarter that the month belongs to ..fo a financial calender year. apr-may-june=Q1, JULY -AUG-sep=Q2, OCT-NOV-dec=q3, Jan -Feb-mar=q4....can anyone help???help is my select statement::SELECT DATENAME(Year,BookingDate) as Year, DATENAME(Month,BookingDate) as Month, COUNT(InvoiceNumber) as [Total Bookings], Sum(NegotiatedSellPrice) as [Total Sale Price]I also wanted to sum the amount quarterly and find the % difference of sales and bookings from previous quarter???Please helpThanks |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-08-27 : 06:09:28
|
| Easier to have a calendar table with the dates and attributes then just join to that.'Q' + convert(varchar(1),(datepart(mm,BookingDate)-1)%3+1)For the calculation would ddefiitely use the calendar table.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
anuraag205
Yak Posting Veteran
58 Posts |
Posted - 2012-08-27 : 08:57:14
|
| Thanks for that...but i tried in report builder to get that...am not hands on @ sql queries. Thanks anyways...u r reply will help me futherThanks |
 |
|
|
|
|
|