ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: OT sql problem
Date Fri, 29 Apr 2005 21:54:20 GMT
I presume you mean without using the queryForList(id, parms, skip, max) call 
in iBATIS. ;-)

Using that it is a snap:

List topNList = queryForList("Customer.getTransactions", parms, 0, n); 

Without that, depending on the database, it can be done.

SQL server has a "top (n)" syntax that you can use, and i think Oracle has a 
rowid that you can use in a nested select (i.e., select blah from (select 
... ) where rowid <= 100 to get the top 100).

In a db with stored procedures it would be fairly straightforward to do, 


On 4/29/05, Nathan Maves <Nathan.Maves@sun.com> wrote:
> Say you had a customer transaction table that held all of the
> transactions for your customers.
> Is there any way in one query to pull back the last n number of
> transactions for all customers?
> This is only a hypothetical instance.... Mine is much more difficult :)
> Nathan

View raw message