title: Oracle SQL compare dates to list
body: <p>I have a list of model, serial, dates (the dates do not exist in the DB). I need to pull model, serial, and most recent call dates prior to the dates given to me. I did find a "solution" that worked using CASE but was wondering if there is a simpler way. When having a list of a 100+ items the OR CASE statements are a bit grueling to work with.</p>
  
  <pre><code>SELECT   M.MODEL_NBR, DEV.SERIAL, i.c_date 
    FROM   device dev, 
           model m, 
           A_DEVICE ad, 
           INTR i 
   WHERE   (DEV.SERIAL, i.intr_id) IN 
              (select serial, max(t.intr_id) over (partition by t.part_id)
                 from intr t, device d
                where t.part_id = AD.PART_ID 
                  and d.device_id = ad.device_id
                  and d.model_type = 'XX'
                  and d.serial in ('1234', '5678')
                  and (1 = (case 
                            when d.serial = '1234'
                             and t.c_date &lt; to_date('10/10/2014', 'mm/dd/yyyy')
                            then 1
                             end)
                    or 1 = (case 
                            when d.serial = '5678'
                             and t.c_date &lt; to_date('11/11/2014', 'mm/dd/yyyy')
                            then 1
                             end)))
           AND M.MODEL_ID = DEV.MODEL_ID 
           and M.MODEL_NBR = '1111' 
           AND DEV.DEVICE_ID = AD.DEVICE_ID 
           AND AD.PART_ID = I.PART_ID 
           order by DEV.SERIAL;
  </code></pre>