MS SQL query Q

rmatthew

Well-known member
Joined
Dec 30, 2002
Messages
115
Location
Texas
I have a query that goes something like this.

select table1.field1 as field1,table1.field2 as field2 from table1 group by field1

SQL Server 2000 gives me an error that the GROUP BY must be in the select list.

I must use this syntax if possible (Alias fields).

Any ideas as to how to fix ?

Thanks in advance.
 
If the dbms has problems resolving the proper field names that exist in multiple tables the query processor may become confused and fail to execute. "Field1" is pretty generic. Youll probably need to use the fully qualified name.

Jon
 
The query is from the same table - maybe this clarifies alittle:

Select plants.name as Plant Name, plants.address as Address from plants group by Plant Name

Grouping by the alias causes the error.
 
Hi,

Why dont you try
Code:
Select plants.name as Plant Name, plants.address as Address from plants 
group by plants.name,plants.address
 
Back
Top