Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting sql error stating column4 was not part of Group By

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Getting sql error stating column4 was not part of Group By
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    Post subject: Re: Getting sql error stating column4 was not part of Group
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    Post subject: Re: Getting sql error stating column4 was not part of Group
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting group data rajella DFSORT/ICETOOL 3 Sun Jan 22, 2017 11:32 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts S922 Error yuvan ABENDS & Debugging 3 Fri Dec 02, 2016 6:58 pm
No new posts Invoke Webservice Fails with DFHPI100... divated CICS 2 Thu Nov 24, 2016 5:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us