SELECT *
FROM Vu_CurRating
WHERE CatId <> 7
AND NOT (
actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public')
AND rhdate < (select getdate()-1095)
)
AND NOT (
ltrating LIKE 'D%'
AND rhdate < (select getdate()-365)
)
ORDER BY SectorCode, companyname,CatId
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]