PDA

Click to See Complete Forum and Search --> : SQL-Grouping?


SAMS
Oct 8th, 1999, 09:23 AM
Hi guys, Is there a way whereby i could select all the content in the table when using group by??

The code below works.
Select CLAIMNO, Format(sum(NET),'######0.00') from export_comp GROUP BY CLAIMNO order by CLAIMNO asc

But when I added (Vend_id & Clinic):
Select CLAIMNO, Vend_id, Clinic, Format(sum(NET),'######0.00') from export_comp GROUP BY CLAIMNO order by CLAIMNO asc

The following error message appears:
"You tried to execute a query that does not include specified expression as part of an aggregate function".

Thks & regards.

I know that i could actually include the other content by adding them into group by, but I did not want that, so is there another way out??

e.g.:
Select CLAIMNO, Vend_id, Clinic, Format(sum(NET),'######0.00') from export_comp GROUP BY CLAIMNO, Vend_id, Clinic order by CLAIMNO asc



[This message has been edited by SAMS (edited 10-08-1999).]

JHausmann
Oct 8th, 1999, 01:57 PM
Not in SQL. When GROUP BY is used, the items in the select statement must either be an aggregate or referenced by the group by (in the case of non-aggregates).

SAMS
Oct 10th, 1999, 08:15 AM
Ok, Thks.