Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Case statement in where clause

$
0
0

Hi,

struggling with the use of a CASE statement in a where clause, can someone help me to get it right please?

My requirement is very simple (i think), in the query below i need to exclude the clause below IF field et.employment_end_reason='Terminate'

and job.valid_to trunc(sysdate)

here is my full query as it currently is

thanks

Steve G

select
cp.emp_no as emp_no
,et.employment_end_reason
,job.valid_to
,cp.person_id
,cp.fname
,cp.lname
,cp.employee_name
,job.job_title
,cp.date_of_birth
,cp.insurance_id
,cp.sex
,cp.marital_status
,p.citizenship
,et.date_of_employment
,et.date_of_leaving
,pa.address1
,pa.address2
,pa.city
,pa.county
,pa.state
,pa.zip_code
,sal.full_time_amount as Salary
,org.code_b as Cost_Centre
,org.org_name
from
company_person cp
left join pers p on cp.person_id = p.person_id
left join...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>