case when. sql statement shows the all record of table. Do not show "Ready to Sale" rows

  • Thread starter Thread starter muhammadanzar
  • Start date Start date
M

muhammadanzar

Guest
hi

select ProductId,ProductName,batch, convert(varchar(10),dbo.ProductShopStock.Expairy,101) as Expairy,
case
when datediff(mm,getdate(), dbo.ProductShopStock.Expairy)<0 then 'Expired'
when datediff(mm,getdate(), dbo.ProductShopStock.Expairy)<6 then 'Near To Expired'
else 'Ready To Sale'
END AS Status
from dbo.ProductShopStock
1615641.png


I want Status column not show "Ready To Sale" Records. How can i record selection and use where clause on status column. status column not exist in my table. can some one guide me.


MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959

Continue reading...
 
Back
Top