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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Need help in making a query

Author  Topic 

abrahamjohn
Starting Member

1 Post

Posted - 2012-10-27 : 02:37:54
Need help in making a query

I have a table as follows - the values are populated automatically to the table.
(guidance columns goes upto column12, from which will select values till Month11 column

Snapshot of Table
https://docs.google.com/open?id=0B5ABzjFXNq33Mm4wMXpMei05Mms
Case1 - If present month is Oct 2012-

GuidanceMonth1 corresponds to Nove 2012

GuidanceMonth2 corresponds to Dec 2012

GuidanceMonth3 corresponds to Jan 2013

GuidanceMonth4 corresponds to Feb 2013 etc


Case2 - If present month is Jan 2013-

GuidanceMonth1 corresponds to Feb 2013

GuidanceMonth2 corresponds to Mar 2013

GuidanceMonth3 corresponds to Apr 2013

GuidanceMonth4 corresponds to May2013 etc

-----------------------------------

I want to have a logic developed as a query where I can select the final result as follows.
if present month is october 2012, jan 2013 , jun 2012 respectively my result table should be like this

Can anyone help?This is required for all months from 1 to 12..irrespective of year it should get data

Snapshot of Table
https://docs.google.com/open?id=0B5ABzjFXNq33dEdHQmw1WmNocW8

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-27 : 08:58:03
I am unable to see any difference between your two screen shots other than the column labels being different. Can you describe or post sample data in a form someone can run copy and past? This blog may help you to create DDL's. http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Also, instead of making all values = 100, if you can use values that are different so someone can discern how they change from input to output, that would be helpful.
Go to Top of Page
   

- Advertisement -