not sure whether your data includes any possible ties, in which case you'll get only the first one. -----Original Message----- From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]On Behalf Of Guang Mei Sent: Thursday, June 17, 2004 1:42 PM To: Oracle-L-freelists Subject: FW: how to write this sql query Yes, It is working. Thanks! Guang > -----Original Message----- Guang, Add MAX(score) over() to your query and that should do it, so: select DISTINCT QUERYID, FIRST_VALUE(SUBJID) OVER (PARTITION BY QUERYID ORDER BY score DESC), MAX(score) OVER() from blastresults where QUERYID=62; - ant ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request@xxxxxxxxxxxxx put 'unsubscribe' in the subject line. -- Archives are at //www.freelists.org/archives/oracle-l/ FAQ is at //www.freelists.org/help/fom-serve/cache/1.html ----------------------------------------------------------------- ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request@xxxxxxxxxxxxx put 'unsubscribe' in the subject line. -- Archives are at //www.freelists.org/archives/oracle-l/ FAQ is at //www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------