Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts FUSE - IBM MQ - CICS integration error Kevin Vaz CICS 1 Mon Sep 18, 2017 4:31 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us