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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -