View previous topic :: View next topic
|
Author |
Message |
tom_mat
New User
Joined: 13 Jul 2005 Posts: 11
|
|
|
|
Hi,
I have a query where i need to find the sum of a column. Also i need to retrieve a column from the same table which has no relation to this sum column.
Select column1, column2, sum(column3) ,column4
from Table1
group by column1, column2.
When I execute this query, I get sql error stating column4 was not part of Group By.
I did not want to use another sql query to fetch just the column4 from table1.
Hence I went for this query which i doubt is an efficient way to do it:
Select column1, column2, sum(column3) ,column4
from Table1
group by column1, column2,column4
Is there a way to do it through a single SQL query without adding column4 in Group By clause?
Thanks,
Tom |
|
Back to top |
|
|
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
|
|
nope!!!!!!!!!!!! |
|
Back to top |
|
|
mkarmegam
New User
Joined: 28 May 2006 Posts: 13 Location: USA
|
|
|
|
Nay! |
|
Back to top |
|
|
Yoyoyo
New User
Joined: 19 Sep 2006 Posts: 26
|
|
|
|
Hey tom_mat,
The rule is...
Except for the columns named in the GROUP BY clause, the SELECT statement must specify any other selected columns as an operand of one of the column functions.
By the way, why you need to find a different method to do the same stuff?
YoYo |
|
Back to top |
|
|
|