I have a small query in my stored procedure:
case when t.status = 4 and (select top 1 nd.status from tableND
where nd.Code= t.Code order by nd.ID desc)=4
then 6 else t.status end) as status from tableTC t
The problem is the speed performance too slow. So, I want to change it to another query.
What should I do now ?