Exforsys

Free Training

To find Maximum

This is a discussion on To find Maximum within the DB2 forums, part of the Database category; I want to find the maximum value in a column in db2. How can I do this?...

Go Back   Exforsys > Database > DB2

Exforsys.com


DB2 DB2 Programming help and Discussions.

Reply

 

LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 12-18-2006, 02:41 AM
Senior Member
 
Join Date: Apr 2006
Posts: 153
cyrus is on a distinguished road
To find Maximum

I want to find the maximum value in a column in db2. How can I do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-21-2006, 06:50 AM
Junior Member
 
Join Date: Aug 2006
Posts: 5
gpraveen_mca is on a distinguished road
The following query will fetch you the Nth maximum value in a column.

select b.column_name from (select distinct column_name from table_name) a,
(select distinct column_name from table_name) b
where a.column_name>=b.column_name
group by b.column_name
having count(b.column_name)=N
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-23-2006, 04:06 PM
Senior Member
 
Join Date: Apr 2006
Posts: 122
rachelle is on a distinguished road
Friend your answer was good and useful.But I want to know whether there is any predefined function for doing this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-27-2006, 04:26 AM
Junior Member
 
Join Date: Feb 2006
Posts: 15
Prabhu N is on a distinguished road
Use SELECT MAX(...) .. in db2 query
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-28-2006, 03:42 PM
Senior Member
 
Join Date: Apr 2006
Posts: 153
cyrus is on a distinguished road
prabhu thanks for your immediate reply.I tried both the suggestion. Can you tell me whether there is any difference in their execution between the two options namely using the predefined function and between the query you gave.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
FAQ: How to find people's E-mail addresses David Alex Lamb Tech FAQ 1 06-24-2007 09:57 AM
FAQ: How to find people's E-mail addresses David Alex Lamb Tech FAQ 0 05-02-2004 06:30 AM
Quarterly ASCII posting of Caldera (SCO) OpenUNIX 8 FAQ Boyd Lynn Gerber Tech FAQ 0 04-25-2004 11:11 PM
Kerberos FAQ, v2.0 (last modified 8/18/2000) Ken Hornstein Tech FAQ 0 04-17-2004 08:28 AM
[FAQ] FileMaker Pro - database for Macintosh and Windows Martin Trautmann Tech FAQ 0 04-17-2004 08:26 AM


All times are GMT -4. The time now is 06:04 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.