select * from Vu_CurRating where ratingid not in(select ratingid from Vu_CurRating where actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public') and rhdate < (select getdate()-1095)) andCatId !=7 and ratingid not in(select ratingid from Vu_CurRating where ltrating like 'D%' and rhdate<(select getdate()-365)) order by SectorCode, companyname,CatId
select * from Vu_CurRating where ratingid not in((select ratingid from Vu_CurRating where actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public') andselect ratingid from Vu_CurRating where actionId in ('withdrawn','Discontinued','Matured','Withdrawn from Public') )and rhdate < (select getdate()-1095)) andCatId !=7 and ratingid not in(select ratingid from Vu_CurRating where ltrating like 'D%' and rhdate<(select getdate()-365)) order by SectorCode, companyname,CatId
select * from Vu_CurRating where ratingid not in((select ratingid from Vu_CurRating where actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public') andselect ratingid from Vu_CurRating where actionId in ('withdrawn','Discontinued','Matured','Withdrawn from Public') )) andCatId !=7 and ratingid not in(select ratingid from Vu_CurRating where ltrating like 'D%' and rhdate<(select getdate()-365)) order by SectorCode, companyname,CatId
and rhdate < (select getdate()-1095)
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
AND NOT ( actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public') AND rhdate < (select getdate()-1095) )