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
 

 

Query to retrive the second AVERAGE Column from the table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
madduri_25

New User


Joined: 09 Mar 2005
Posts: 3

PostPosted: Fri Apr 29, 2005 3:20 pm    Post subject: Query to retrive the second AVERAGE Column from the table
Reply with quote

icon_question.gif
hai all,
pls reply with sql query how we retrieve the second avg value from column of a particular table is there any sutable query pls fwd it
regards
madduri_25 team
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Apr 29, 2005 4:26 pm    Post subject: Re: Query to retrive the second AVERAGE Column from the tabl
Reply with quote

Second Avg means what....will you be please more clear.......

Regards,

Priyesh
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Wed May 04, 2005 1:49 pm    Post subject: Re: Query to retrive the second AVERAGE Column from the tabl
Reply with quote

Hi Madduri,

Average is a group function which gives a single result by taking a group of rows as input. So we will have only one average for a column. Please clarify us about your question in more detail.

Eg: select avg(sal) from myuser.emp;

Returns average of salary which is only one value. So what is the second average vale?

Thanks,
Reddy.
Back to top
View user's profile Send private message
ssowjanya

New User


Joined: 29 Apr 2005
Posts: 13

PostPosted: Wed May 04, 2005 1:54 pm    Post subject: Re: Query to retrive the second AVERAGE Column from the tabl
Reply with quote

Hi Madduri,
Is the query is like this...
write a query to find the second max sal?
Back to top
View user's profile Send private message
nrsmca

New User


Joined: 25 May 2005
Posts: 14

PostPosted: Fri Jun 10, 2005 2:37 pm    Post subject: Re: Query to retrive the second AVERAGE Column from the tabl
Reply with quote

Hi,

Select avg(salary) from Table1 a where 2 =
(select count (*) from Table1 b where b.salare >= a.salary);

N th Max. Avg value calculation,
Select avg(salary) from Table1 a where n =
(select count (*) from Table1 b where b.salare >= a.salary);

Regards,
N.R.S,mca
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Wed Jun 15, 2005 3:01 pm    Post subject:
Reply with quote

Hi NRS,

Sorry I am not getting. What you are trying for. U mean to find the average of salries after exclusing the highest salary. But as I know there is no concept of second average??? If I am wrong please correct me with explanation.

Thanks,
Reddy.
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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