[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Possible Alternative to Max(EFFDT) and LOOPS=1: ROWNUM = 1



In regards to the recent discussion around SQR's using
the LOOPS = 1 and max(effdt):


Instead of this:

------------------------------------
begin-select
L.TOTAL_COVRG_RATE

from ps_flat_rate_tbl l
where l.RATE_ID = &K.RATE_TBL_ID
  and l.effdt = (select max(effdt) from
                  ps_flat_rate_tbl
                 where flat_rate_id = l.flat_rate_id
                   and effdt <= $AsOfDate)
end-select
------------------------------------


and instead of this:

------------------------------------
begin-select loops = 1

L.TOTAL_COVRG_RATE
from ps_flat_rate_tbl l
where l.RATE_ID = &K.RATE_TBL_ID
  and l.effdt <= $AsOfDate
order by l.effdt desc
end-select
------------------------------------


Does the following always work?  And if so, is it
acceptable/recommended?

------------------------------------
begin-select

L.TOTAL_COVRG_RATE
from ps_flat_rate_tbl l
where l.RATE_ID = &K.RATE_TBL_ID
  and l.effdt <= $AsOfDate
  AND ROWNUM = 1   !<---------??????????????????
order by l.effdt desc

end-select
------------------------------------

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com