IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting sql error stating column4 was not part of Group By


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tom_mat

New User


Joined: 13 Jul 2005
Posts: 11

PostPosted: Wed Oct 18, 2006 7:50 pm
Reply with quote

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
View user's profile Send private message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Wed Oct 18, 2006 10:31 pm
Reply with quote

nope!!!!!!!!!!!!
Back to top
View user's profile Send private message
mkarmegam

New User


Joined: 28 May 2006
Posts: 13
Location: USA

PostPosted: Thu Oct 19, 2006 2:59 am
Reply with quote

icon_sad.gif Nay!
Back to top
View user's profile Send private message
Yoyoyo

New User


Joined: 19 Sep 2006
Posts: 26

PostPosted: Wed Nov 01, 2006 5:02 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top