Re: same reseult set with less column

From: Ed Prochak <>
Date: Sun, 28 Sep 2008 19:46:20 -0700 (PDT)
Message-ID: <>

On Sep 26, 2:40 pm, "" <> wrote:
> Thanks everybody. Let me explain what I am really trying to do that
> let me to having the original question.
> I use the top-N query using ROWNUM to get data. The returned resultset
> is returned to my web app which uses jdbc to access the the resultset
> and displays data in a table.
> The top-N query returns the extra column of rownum. Some queries in my
> app need the top-N query, some don't. I would like to use only one set
> of code to display the data returned from the resultsets therefore
> some tables will be displayed correctly, some will be displayed with
> an extra column rownum.
> That's why I am thinking about having the top-N query resultsets to be
> filtered by some other query to get rid of the column rownum, instead
> of fixing code in the web app for different tables.
> Thanks,
> DT

Since you are using JAVA, why not open the cursor, fetch the N rows you need and close the cursor?

No offense intended, DT, but I've never been a fan of ROWNUM. It leads to wrong thinking about database results. The row count treats results like records instead of rows. And funny how it always seems to be web apps that use this most often.

Can you describe what constitutes the TOP N rows? What ordering do you use? Often if you can describe the rule you can code it into the query.

  Ed Received on Sun Sep 28 2008 - 21:46:20 CDT

Original text of this message