Stretchwickster
Programmer
What I'm trying to do is create a SQL query that internally generates the following result set without querying an actual table/view...
The respective values in the CALENDAR_YEAR column above can be generated using the following function calls...
...and I have a function that returns the appropriate letter shown in the ABBR column above when it is passed a date.
My question is: how do I actually formulate the query to return rows when I'm not interacting with a table/view?
My limited SQL ability only allows me to generate columns in a single row when not querying a table/view.
Any advice would be much appreciated.
Clive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
Code:
DESC ABBR CALENDAR_YEAR
Next Year N 2013
This Year C 2012
Last Year L 2011
Older Year O 2010
The respective values in the CALENDAR_YEAR column above can be generated using the following function calls...
Code:
YEAR(GETDATE())+1
YEAR(GETDATE())
YEAR(GETDATE())-1
YEAR(GETDATE())-2
My question is: how do I actually formulate the query to return rows when I'm not interacting with a table/view?
My limited SQL ability only allows me to generate columns in a single row when not querying a table/view.
Any advice would be much appreciated.
Clive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096