sql - Select rows by applying whatever condition(if or case) -
i have set of records suppose below:
id name status date 1 xx 1 2016-06-27 14:05:17.447 2 yy 2 2016-06-27 14:05:17.447 3 zz 1 2016-06-27 14:05:17.447 4 aa 2 2016-06-27 14:05:17.447 5 bb 2 2016-06-27 14:05:17.447
i want select rows above rows have status=1, want apply condition that
select if status=1 , date<=getdate
how can that?
select id, name, case when status =1 , date<getdate() 'i want select row' else don't want select row end statuss ,date yourtable
update: per edit,you need apply conditions in clause
select * yourtable status=1 , date<getdate()
Comments
Post a Comment