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

Aggregate function -MAX, What this function exactly does


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

New User


Joined: 09 Jan 2007
Posts: 2
Location: Hyderabad

PostPosted: Mon Feb 19, 2007 4:23 pm
Reply with quote

Hi ,

Please help me in understanding the MAX function ??
What this function exactly does ??

Since I have big three table join query and not able to understand it clearly.

The query looks like

SELECT
MAX(COLUMNA) ,
MAX(COLUMNB) ,
MAX(COLUMNC) ,
MAX(COLUMND) ,
MAX(COLUMNE) ,
MAX(COLUMNF) ,
MAX(COLUMNG) ,
MAX(COLUMNH) ,
COLUMNI ,
COLUMNJ ,
SUM(COLUMNK) ,
SUM(COLUMNL) ,
SUM(COLUMNM) ,
-- *
FROM
TABLE1
GROUP BY
COLUMNA
COLUMNB
COLUMNC
COLUMND
COLUMNE


aS OF I KNOW the MAX function should fetch the maximum value so should fetch one row.But where this query is fetching multiple rows.

Pleazz help me to understand this.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Mon Feb 19, 2007 4:28 pm
Reply with quote

Hi There,

Ya it will fetch multiple rows u will get one row for every record present in table where first eight field will be replaced by max value for that field in table , then u will get COLUMNI & COLUMNj for that record after that last three field will conatin the sum value for respected field
Back to top
View user's profile Send private message
siva-ongole

New User


Joined: 09 Jan 2007
Posts: 2
Location: Hyderabad

PostPosted: Mon Feb 19, 2007 4:45 pm
Reply with quote

Hi Moderator,

That means if i have 100 rows in table and only one row is having the maximum values then you mean all 100 rows will be displayed with actual columnI and COLUMNJ value but other values will be maximum values ???

if this is the case that is not happening.Will send u sample data returned.

003 18095 70 70 000 S 029 003 010 P
003 18095 70 70 000 S 029 003 010 Y
003 18264 70 70 000 S 014 003 010 P
003 18264 70 70 000 S 014 003 010 Y

I know that 18264 is the maximum value for the columnb.Then why is the 18095 is also getting returned.

thanks
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Mon Feb 19, 2007 4:49 pm
Reply with quote

Hi there ,

Apologies for my prev post i have not looked on group by clause
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 Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
No new posts INSYNC option with same function as I... JCL & VSAM 0
Search our Forums:

Back to Top