[EMAIL PROTECTED] wrote:
 I have a file with the columns: StockSymbol, OptionSymbol,
StockPrice, StrikePrice, ExpiryDate

For each StockSymbol, ExpiryDate, I would like to list just 4 of the
records where the StrikePrice is lower than the StockPrice.

This should do it:

select * from Options o1
where rowid in (
   select o2.rowid from Options o2
where o1.StockSymbol = o2.StockSymbol and o1.ExpiryDate=o2.ExpiryDate
       and o2.StrikePrice < o2.StockPrice
   limit 4);


I wouldn't be surprised if it turns out to be faster to just retrieve all records and skip over all but the first four in each group in your program.

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to