Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JSP Interest »

Re: Top 3

Raju BSN

2003-07-29

Replies:

Hi,

Try the following sample logic if you are not able to get it done in the SQL
Query it self...

int top1 = 0;
int top2 = 0;
int top3 = 0;

int resultsetData = 0;


While(resultset.next()) {

resultsetData = resultset.getXXX("column_name");

if(resultsetData > top1) {
if(top2 < top1) {
 if(top3 < top2) {
  top3 = top2;
 }
top2 = top1;
}
top1 = resultsetData;
}
if(resultsetData < top1 && resultsetData > top2) {
if(top3 < top2) {
 top3 = top2;
}
top2 = resultsetData;
}
if(resultsetData < top1 && resultsetData < top2 && resultsetData > top3 ) {
top3 = resultsetData;
}

}

Hope this will help

Regards
Raju



----- Original Message -----
From: "Pradeep Kumar" <pradeepk@(protected)>
To: <JSP-INTEREST@(protected)>
Sent: Tuesday, July 29, 2003 4:33 PM


> Use a query like this:
>
> select max(emp_id) from employee where emp_id <>(select max(emp_id) from
> employee)
>
> -----Original Message-----
> From:  Lakshmeenarayana [mailto:lnarayana@(protected)]
> Sent:  Tuesday, July 29, 2003 4:32 PM
> To:   JSP-INTEREST@(protected)
> Subject:
>
> put them in integer array and use Arrays.sort(int[] arr) method.
>
>
>
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:JSP-INTEREST@(protected)
> Sent: Tuesday, July 29, 2003 3:48 PM
> To: JSP-INTEREST@(protected)
> Subject:
>
>
> hi i need a misc..hlp
> this is no way related to this group but still i put this question..since
i
> know this group has elite personalities with logical brain..
> assume there is a series of nos is 3,4,5,6,7,9
> the nos are from data base .. i want the maximum three nos in a three
> variables ..
> any java code will be helpful
> no arrays please..
>
> Best Regards
> Peter
>
> =========================
> To unsubscribe: mailto listserv@(protected)
> JSP-INTEREST".
> For digest: mailto listserv@(protected)
> DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
> http://java.sun.com/products/jsp
> http://archives.java.sun.com/jsp-interest.html
> http://forums.java.sun.com
> http://www.jspinsider.com
>
>
===========================================================================
> To unsubscribe: mailto listserv@(protected)
> JSP-INTEREST".
> For digest: mailto listserv@(protected)
> DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
> http://java.sun.com/products/jsp
> http://archives.java.sun.com/jsp-interest.html
> http://forums.java.sun.com
> http://www.jspinsider.com
>
>
>
> DISCLAIMER:
> This message (including attachment if any) is confidential and may be
privileged. Before opening attachments please check them for viruses and
defects. MindTree Consulting Private Limited (MindTree) will not be
responsible for any viruses or defects or any forwarded attachments
emanating either from within MindTree or outside. If you have received this
message by mistake please notify the sender by return e-mail and delete
this message from your system. Any unauthorized use or dissemination of this
message in whole or in part is strictly prohibited. Please note that
e-mails are susceptible to change and MindTree shall not be liable for any
improper, untimely or incomplete transmission.
>
> To unsubscribe: mailto listserv@(protected)
JSP-INTEREST".
> For digest: mailto listserv@(protected)
DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
> http://java.sun.com/products/jsp
> http://archives.java.sun.com/jsp-interest.html
> http://forums.java.sun.com
> http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto listserv@(protected)".
For digest: mailto listserv@(protected)".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com


©2008 junlu.com - Jax Systems, LLC, U.S.A.