Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Catch 22 on group by
Message
From
17/05/2001 16:33:57
 
 
To
17/05/2001 11:05:44
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00508311
Message ID:
00508507
Views:
20
>Hi,
>
>I'm doing a select that contains a text field and trying to do a group by. SQL telle me I can't have text fields in the group clause. Fine- I take it out of the group clause and SQL now tells me that the statement can't run because the field isn't in an aggregate function or the group by clause!
>
>So - what the heck does it want?
>
>thanks,

You don't actually want to group by the text data though, do you?

What you are telling it to do is give you the contents of a field, but you are creating a group. So, say there are 10 records in your group, it doesn't know which text field to give you.

What data do you want? If you have:

ID MyTEXT
1 This is some
1 text that is stored
1 in these record
2 but how would sql
2 know which text
2 to give you, since there
2 is more than one record in a group

Then you try to:

SELECT MyTEXT FROM MyTable GROUP BY ID

It can do that... since text isn't in the group for the group with ID = 1 what text would you want?

So, perhaps if you give us an idea of your table, and the results you want we could help ya!

BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform