Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic query column name

Status
Not open for further replies.

99Chuck99

Programmer
Dec 11, 2003
67
US
New to SQL server and was wondering if the following snipit of code can be done. I would like to name the column in the query to the month with the AS statement. Thanks in advance.

SUM(CASE WHEN datepart(MONTH, (DATEADD(M, - 1, GETDATE())))= DATEPART(MONTH, dbo.ACTION.ACTION_DATE) THEN 1 ELSE 0 END) AS datepart(MONTH,(DATEADD(M, - 1, GETDATE()))),
 
Does anybody have any ideas on how I could achieve this type of dynamic field naming. I'm tring to pull current month and the two previous months at any period of the year. Thanks again....
 
Why?
That will make your frontend much more difficult.
Better stay with constant recordsset, than to make your frontend code unreadable :)

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top