Help with case when

Giganews Newsgroups
Subject: Help with case when
Posted by:  dwerden (dwerd…
Date: 1 Aug 2006

I need help.
This is the code I currently have and need to change:
  p.code as "Code",
  p.detail_type as "Detail Type",

p.code shows diagnostic code numbers and billing procedure numbers
while p.detail_type indicate which is which. Diagnostic code numbers
are designated as '-2' (minus 2) in the 'detail_type' and procedure
codes are designated as '-4' (minus 4) in the 'detail_type.' The query
I am using now (see below) gives me duplicate appt dates to show both
the diagnostic code and procedure code. I need to clean this up a bit.

What I want this to do is find a statement that will separate the codes
into diagnosis numbers and procedure numbers and place these numbers in
different columns in the ad hoc report that is generated.

I would like something to the effect of:
If p.detail_type = -2 then place the code number in a column known as
If p.detail_type - -4 then place the code number in a column known as

Any ideas on how to write this?

/* Individual Client Task List */

  a.Provider as "Provider",
  a.Apptdate as "Session Date",
  a.Appttype as "Session Type",
  p.code as "Code",
  p.detail_type as "Detail Type",
  a.Complaint1 as "Note Written",
  a.Signoffinits as "Co-Signed",
  a.Lastname as "Lastname",
  a.Firstname as "Firstname"
>From Appointments a, Patientmedicalrecords p
Where a.uniquenumber = p.appt_uniquenumber
  and a.Division = 3
  and a.Inactive = 0
  and a.Personal = 0
  and a.Ingroup = 0
  and a.Appttype not like 'TELE'
  and a.Apptdate between '1-Jul-2006' and sysdate - 1
  and a.Appttype not in ('AEP2','AEP4','AOD','TOCE2','TOCE4','ETOH2
Class','AEP4 Class','AOD1 Class')
  and (substr(a.Complaint1,1,2) = 'TS'
      or a.Complaint1 like 'Secretary Signed'
      or a.Complaint1 is null
      or a.Signoffinits is null)
  and a.Patientnumber not in ('57629','82362','125163','139842')
Order by

Thanks for your help.  dwerden.