Home » SQL & PL/SQL » SQL & PL/SQL » Group By
Group By [message #953] Fri, 15 March 2002 00:57 Go to next message
homer
Messages: 17
Registered: October 2001
Junior Member
is it possible to make a group by on selected columns.
Ex:
code nom salary
1 A 10
2 B1 10
2 B2 30

If I type a group by

select code,
nom,
sum(salary)
from my_table
group by code, nom

the result is 3 lines.

But B1 and B2 are a mistake.
It's the same person.
So I want to print one line
Only Code 1 and Code 2.
It's possible to choose with Access (group by first), and what about Oracle.

Thanks for your Answer.
Re: Group By [message #954 is a reply to message #953] Fri, 15 March 2002 01:03 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
try this

select code,sum(salary)
from my_table
group by code
Re: Group By [message #958 is a reply to message #953] Fri, 15 March 2002 04:56 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
you said
"Thanks a lot for your message, but I want to see others colums.And with your code, only one column displayed."

the only column "code" can be displayed as it is included group by clause and other can not.

if u think logically , what u r talking is wrong.
u r summing the salary for particular codes and that code may be belongs to different rows

e.g.
rows are
1 A 10
2 B1 10
2 B2 30
and result are
1 10
2 40***what u want to see here

hope it helps!!!
Previous Topic: tables in non-default tablespace
Next Topic: 06512
Goto Forum:
  


Current Time: Tue Apr 23 14:55:59 CDT 2024