Just the latest - TOP or ??

  • Thread starter Thread starter warway
  • Start date Start date
W

warway

The following procedure returns the data I want but I need to show just the
latest instance of each s.CurrencyCode in order to populate a combobox, any
help greatly appreciated!


Alter PROCEDURE dbo.sp_ROECurrent3 @LessDate datetime

AS

SELECT s.ROEID,s.CurrencyCode, s.ExchangeRATE, s.ROEDate, o.ROEWeighting,
o.BaseCurrency, 'Weighted ROE' =

CASE

WHEN s.CurrencyCode <> o.BaseCurrency THEN s.exchangeRate - (s.ExchangeRATE
*(1+o.ROEWeighting) - s.exchangeRate)

ELSE 1

END,

CAST(o.CurrencyName AS varchar(20)) AS 'Currency'

FROM ROECurrentView o JOIN tblkpROE s ON o.ROEDate = s.ROEdate AND
s.CurrencyCode=o.CurrencyCode

GROUP BY
s.ROEID,s.CurrencyCode,s.ExchangeRate,s.ROEDate,o.ROEWeighting,o.BaseCurrenc
y,o.CurrencyName,o.CurrencyCode

HAVING MAX(DISTINCT o.ROEDate) <= @LessDate

ORDER by o.CurrencyCode



Warway
 
No Sorry that didn't work

Still the same records return as before...everything before the date I enter
as @Lessdate

Warway
 
Back
Top