Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group by trouble-"not a GROUP BY expression"

Status
Not open for further replies.

olichap

Programmer
Mar 20, 2001
389
US
I have a basic select statement that just lists those fields from one table (a view actually) I wish to return (could also just say select *).

example:

Select fld1, fld2, fld3 from ViewTable group by fld1

Oracle returns the "not a GROUP BY expression" error message. I've compared my syntax with other examples and am starting to worry that I'm completely blind (for not having seen whatever is wrong).

Any guidance would be greatly appreciated.

Thanks,

O.
 
you have to put all the columns in group by expressions if you are not using aggregate function on particular column

Nikhil
 
You are saying to Oracle to group all the distinct values for fld1 and display a single row. So the other two rows must also be agregated up into something that returns a single row.
E.G.
select fld1, sum(fld2), max(fld3) from viewtable group by fld1;

So for the data
fld1 fld2 fld3
~~~~ ~~~~ ~~~~
1 2 2
1 4 1
2 10 4
2 10 5

You would return
1 6 2
2 20 5

Yes?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top