If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Another group by ntext

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-02-09, 03:23
talgiladi talgiladi is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Another group by ntext

I'm trying to run a query with group by on NTEXT.
I saw the solution written on
Basic Query: Alternatives to 'Group By' for nText column to cast the ntext to varchar
and now I'm running the query:

" SELECT name, xmlFields, MAX(accountId)
FROM tblQueries
GROUP BY name, CAST(xmlFields as varchar(8000)) "

where xmlFields is my ntext fields
but I getting an error message:
Error 8120: Column 'xmlFields' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Reply With Quote
  #2 (permalink)  
Old 11-02-09, 04:28
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
The message is correct - xmlFields is in the select list but not in the GROUP BY clause. In the group by clause you have another column entirely: CAST(xmlFields as varchar(8000) is not the same as xmlFields

BTW - my hope is that is enough of a hint to guide your thinking to the solution - always better than just being handed it
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 11-02-09, 04:37
talgiladi talgiladi is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Thanks!

SELECT name,CAST(xmlFields as varchar(8000)) as xmlFields, MAX(accountId)
FROM tblQueries
GROUP BY name, CAST(xmlFields as varchar(8000))
Reply With Quote
Reply

Tags
groupby, ntext

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On