Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Catch 22 on group by
Message
De
17/05/2001 16:33:57
 
 
À
17/05/2001 11:05:44
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00508311
Message ID:
00508507
Vues:
19
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform