Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need help to eliminate values from resultant record using view


Need help to eliminate values from resultant record using view

Author
Message
maida_rh
maida_rh
SSC Rookie
SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)

Group: General Forum Members
Points: 46 Visits: 111
I want to eliminate ('withdrawn','Discontinued','Matured','Withdrawn from Public') from the resultant records but not succeed
QUERY :
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)
)
and
CatId !=7 and
ratingid not in
(
select ratingid from Vu_CurRating where ltrating like 'D%' and rhdate<(select getdate()-365)
)
order by SectorCode, companyname,CatId


I want this query like this as it is not eliminating actiontype('withdrawn','Discontinued','Matured','Withdrawn from Public') from the resultant records for this I edit the query :
select * from Vu_CurRating where ratingid not in
(
(
select ratingid from Vu_CurRating where actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public') and
select ratingid from Vu_CurRating where actionId in ('withdrawn','Discontinued','Matured','Withdrawn from Public')
)
and
rhdate < (select getdate()-1095)
)
and
CatId !=7 and
ratingid not in
(
select ratingid from Vu_CurRating where ltrating like 'D%' and rhdate<(select getdate()-365)
)
order by SectorCode, companyname,CatId



but still no change except when I change :

select * from Vu_CurRating where ratingid not in
(
(
select ratingid from Vu_CurRating where actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public') and
select ratingid from Vu_CurRating where actionId in ('withdrawn','Discontinued','Matured','Withdrawn from Public')
)
) and
CatId !=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)


Any solution to this ?
Thanks in advance
ChrisM@home
ChrisM@home
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1161 Visits: 9733
SELECT * 
FROM Vu_CurRating
WHERE CatId <> 7

   AND NOT (
      actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public')
      AND rhdate < (select getdate()-1095)
   Wink

   AND NOT (
      ltrating LIKE 'D%'
      AND rhdate < (select getdate()-365)
   Wink

ORDER BY SectorCode, companyname,CatId




Low-hanging fruit picker and defender of the moggies





For better assistance in answering your questions, please read this.




Understanding and using APPLY, (I) and (II) Paul White

Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
maida_rh
maida_rh
SSC Rookie
SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)

Group: General Forum Members
Points: 46 Visits: 111
I tried ur solution but stilll code return the same result as my query return ....
PiMané
PiMané
Mr or Mrs. 500
Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)

Group: General Forum Members
Points: 592 Visits: 1334
maida_rh (10/10/2012)
I tried ur solution but stilll code return the same result as my query return ....

Please send some sample data and result obtained and the result expected...



If you need to work better, try working less...
ChrisM@home
ChrisM@home
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1161 Visits: 9733
maida_rh (10/10/2012)
I tried ur solution but stilll code return the same result as my query return ....


   AND NOT (
      actiontype in ('withdrawn','Discontinued','Matured','Withdrawn from Public')
      AND rhdate < (select getdate()-1095)
   Wink



This will return rows where actiontype is in 'withdrawn','Discontinued','Matured','Withdrawn from Public', but only if they are more recent than 1095 days ago. I think you are getting confused with the logic. Try writing down the rules - for us - it will probably help you too.


Low-hanging fruit picker and defender of the moggies





For better assistance in answering your questions, please read this.




Understanding and using APPLY, (I) and (II) Paul White

Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search