Home » SQL & PL/SQL » SQL & PL/SQL » Select statement with group by
Select statement with group by [message #253645] Tue, 24 July 2007 08:37 Go to next message
arik_x
Messages: 6
Registered: July 2007
Junior Member
Hello,

I was wondering how can I select a column from a table, but I do not need to include this column in group by clause?

Thanks
Re: Select statement with group by [message #253646 is a reply to message #253645] Tue, 24 July 2007 08:45 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
I'm afraid this question doesn't seem to make sense (maybe I'm just being dense) Please provide more info
Re: Select statement with group by [message #253647 is a reply to message #253645] Tue, 24 July 2007 08:47 Go to previous messageGo to next message
arik_x
Messages: 6
Registered: July 2007
Junior Member
Table columns: a, b, c, d, e, f, g

How can I select all the columns, but group by only b, c, d, e, f, and g.

Re: Select statement with group by [message #253648 is a reply to message #253645] Tue, 24 July 2007 08:53 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Think logically about what you are asking for.

A simple case

There is an table emp with dept_no, mgr_id, emp_id.

You are basically saying

I want to group by dept_no, mgr_id but also give me all the emp_ids.

It makes no sense.

[Updated on: Tue, 24 July 2007 08:53]

Report message to a moderator

Re: Select statement with group by [message #253783 is a reply to message #253645] Tue, 24 July 2007 16:31 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
select a, b, c, d, e, f, g
from my_table
group by b, c, d, e, f, g;

If you are only pulling from a single table, this will have the effect of negating the group by. However if you had something like

select a.a, b.b, b.c, b.d, b.e, b.f, b.g
from my_table a, my_other_table b
where a.a = b.a
group by b.b, b.c, b.d, b.e, b.f, b.g;

might return useful groupings.
Previous Topic: How to identify / prevent pl/sql function calls in infinite loop?
Next Topic: Problem executing UNIX commands from PL/SQL
Goto Forum:
  


Current Time: Sat Dec 07 05:02:46 CST 2024