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 |
kamii47
Constraint Violating Yak Guru
353 Posts |
Posted - 2013-03-02 : 10:11:21
|
I am facing issues with my queryselect week_number,yearfrom accounting_calenderwhere week_number<=3and week_number>3-6and year=2013here in this query im passing the week_number "3" and year "2013" through my reporting tool.im getting the following output| Week_number | year |------------------------------| 3 | 2013 || 2 | 2013 || 1 | 2013 |but here in my accounting calender table i got even the entries for 2012 too.so here im subtracting "-6", so it has to go to previous year weeks also..iam looking for something like below output| Week_number | year |------------------------------| 51 | 2012 || 52 | 2012 || 53 | 2012 || 3 | 2013 || 2 | 2013 | | 1 | 2013 |kindly guide me.i have only read-only accessKamran ShahidPrinciple Engineer Development(MCSD.Net,MCPD.net) |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-02 : 12:07:44
|
do you've any other columns in accounting_calendarlike date,dateid etc?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-03-04 : 03:12:34
|
[code]select TOP 6 week_number ,yearfrom accounting_calenderwhere (year * 100) + week_number <= (2013 * 100) + 3order by year desc, week_number[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-04 : 04:24:33
|
hmm...i thought op wanted last x weeks from recent week------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|