﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 7,2000 / SQL Server Newbies  / DateName Query / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 17:30:35 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: DateName Query</title><link>http://www.sqlservercentral.com/Forums/Topic403852-169-1.aspx</link><description>in the ORDER BY section of a statement, you can refer to data by the alias that was assigned to it, isntead of the function. will that help you out?ie SELECT MAX(something) as ThatThing,DateName (Month, ChargeDate) As DaDateFrom Some Tablegroup by SomeKey[b]Order By ThatThing,DaDate[/b]</description><pubDate>Thu, 27 Sep 2007 19:27:21 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>DateName Query</title><link>http://www.sqlservercentral.com/Forums/Topic403852-169-1.aspx</link><description>I am using the function in a Query: ORDER BY DateName (Month, ChargeDate).  I am trying to do one query with three columns: DateNumber (i.e. December would be number 12, etc.), DateName, and Total (the total comes from the SUM of some other items using WHERE statements).I can create a single table with the DateNumber and Total columns, but when I try to add the DateName column, I get an error.  The error says that the SELECT statement is invalid because the DateName is not contained in either an aggregate function or the GROUP BY statement.  I can create a table with ONLY the DateName column and it works correctly...now if only I could combine these two queries.  I even tried making the GROUP BY and ORDER BY statements the same DateName (Month, CHargeDate), but I still got the same error as before.  I either need a resource that gives examples of an entire Query (as opposed to just the ORDER BY DateName statement), also maybe one that would be useful in future situations, or maybe someone knows what I am talking about and can tell me why I might be getting that error.</description><pubDate>Thu, 27 Sep 2007 19:19:47 GMT</pubDate><dc:creator>kerry_caskey</dc:creator></item></channel></rss>