title: Formatting my table Oracle SQL
body: <p>I have a table that has the following columns</p>
  
  <pre><code>select a.ssrmeet_crn
        ,a.ssrmeet_begin_time
        ,a.ssrmeet_end_time
        ,a.ssrmeet_start_date
        ,a.ssrmeet_end_date
        ,a.ssrmeet_sun_day
        ,a.ssrmeet_mon_day
        ,a.ssrmeet_tue_day
        ,a.ssrmeet_wed_day
        ,a.ssrmeet_thu_day
        ,a.ssrmeet_fri_day
        ,a.ssrmeet_sat_day
  from   ssrmeet a
  where  a.ssrmeet_term_code = 201730
  and    a.ssrmeet_crn = 32789
  </code></pre>
  
  <p>A row for one class would look like this</p>
  
  <pre><code>SSRMEET_CRN SSRMEET_BEGIN_TIME  SSRMEET_END_TIME    SSRMEET_START_DATE      SSRMEET_END_DATE        SSRMEET_SUN_DAY SSRMEET_MON_DAY SSRMEET_TUE_DAY SSRMEET_WED_DAY SSRMEET_THU_DAY SSRMEET_FRI_DAY SSRMEET_SAT_DAY
  32789       1000                1050                1/8/2018 12:00:00 AM    5/4/2018 12:00:00 AM                    M                               W                               F   
  </code></pre>
  
  <p>I need it to list out every class meet like this</p>
  
  <pre><code>CRN     START_DATE              END_DATE
  32789   1/15/2018 10:00:00 AM   1/15/2018 10:50:00 AM
  32789   1/22/2018 10:00:00 AM   1/22/2018 10:50:00 AM
  32789   1/29/2018 10:00:00 AM   1/29/2018 10:50:00 AM
  32789   2/05/2018 10:00:00 AM   2/05/2018 10:50:00 AM
  32789   2/12/2018 10:00:00 AM   2/12/2018 10:50:00 AM
  32789   2/19/2018 10:00:00 AM   2/19/2018 10:50:00 AM
  32789   2/26/2018 10:00:00 AM   2/26/2018 10:50:00 AM
  32789   3/05/2018 10:00:00 AM   3/05/2018 10:50:00 AM
  32789   3/12/2018 10:00:00 AM   3/12/2018 10:50:00 AM
  32789   3/19/2018 10:00:00 AM   3/19/2018 10:50:00 AM
  32789   3/26/2018 10:00:00 AM   3/26/2018 10:50:00 AM
  32789   4/02/2018 10:00:00 AM   4/02/2018 10:50:00 AM
  32789   4/09/2018 10:00:00 AM   4/09/2018 10:50:00 AM
  32789   3/16/2018 10:00:00 AM   3/16/2018 10:50:00 AM
  32789   4/23/2018 10:00:00 AM   4/23/2018 10:50:00 AM
  32789   4/30/2018 10:00:00 AM   4/30/2018 10:50:00 AM
  32789   1/10/2018 10:00:00 AM   1/10/2018 10:50:00 AM
  32789   1/17/2018 10:00:00 AM   1/17/2018 10:50:00 AM
  32789   1/24/2018 10:00:00 AM   1/24/2018 10:50:00 AM
  32789   1/31/2018 10:00:00 AM   1/31/2018 10:50:00 AM
  32789   2/07/2018 10:00:00 AM   2/07/2018 10:50:00 AM
  32789   2/14/2018 10:00:00 AM   2/14/2018 10:50:00 AM
  32789   2/21/2018 10:00:00 AM   2/21/2018 10:50:00 AM
  2789    2/28/2018 10:00:00 AM   2/28/2018 10:50:00 AM
  32789   3/07/2018 10:00:00 AM   3/07/2018 10:50:00 AM
  32789   3/14/2018 10:00:00 AM   3/14/2018 10:50:00 AM
  32789   3/21/2018 10:00:00 AM   3/21/2018 10:50:00 AM
  32789   3/28/2018 10:00:00 AM   3/28/2018 10:50:00 AM
  32789   4/04/2018 10:00:00 AM   4/04/2018 10:50:00 AM
  32789   4/11/2018 10:00:00 AM   4/11/2018 10:50:00 AM
  32789   4/18/2018 10:00:00 AM   4/18/2018 10:50:00 AM
  32789   4/25/2018 10:00:00 AM   4/25/2018 10:50:00 AM
  32789   5/02/2018 10:00:00 AM   5/02/2018 10:50:00 AM
  32789   1/12/2018 10:00:00 AM   1/12/2018 10:50:00 AM
  32789   1/19/2018 10:00:00 AM   1/19/2018 10:50:00 AM
  32789   1/26/2018 10:00:00 AM   1/26/2018 10:50:00 AM
  32789   2/02/2018 10:00:00 AM   2/02/2018 10:50:00 AM
  32789   2/09/2018 10:00:00 AM   2/09/2018 10:50:00 AM
  32789   2/16/2018 10:00:00 AM   2/16/2018 10:50:00 AM
  32789   2/23/2018 10:00:00 AM   2/23/2018 10:50:00 AM
  32789   3/02/2018 10:00:00 AM   3/02/2018 10:50:00 AM
  32789   3/09/2018 10:00:00 AM   3/09/2018 10:50:00 AM
  32789   3/16/2018 10:00:00 AM   3/16/2018 10:50:00 AM
  32789   3/23/2018 10:00:00 AM   3/23/2018 10:50:00 AM
  32789   3/30/2018 10:00:00 AM   3/30/2018 10:50:00 AM
  32789   4/06/2018 10:00:00 AM   4/06/2018 10:50:00 AM
  32789   4/13/2018 10:00:00 AM   4/13/2018 10:50:00 AM
  32789   4/20/2018 10:00:00 AM   4/20/2018 10:50:00 AM
  32789   4/27/2018 10:00:00 AM   4/27/2018 10:50:00 AM
  32789   5/04/2018 10:00:00 AM   5/04/2018 10:50:00 AM
  </code></pre>
  
  <p>The day columns just have indicators if the class meets on that day. (Sunday 'U', 
  Monday 'M', 
  Tuesday 'T', 
  Wednesday 'W', 
  Thursday 'R', 
  Friday 'F', 
  Saturday 'S')</p>
  
  <p>and the begin times and end times are in 24hour format.</p>
  
  <p>I've tried a couple different paths to try and solve including using connect by this but I'm stumped.</p>
  
  <p>This is as far as I've gotten with it. I can generate the first dates with it but I don't know where to go from here..</p>
  
  <pre><code>with
  data_prep as(
  select 'U' dotw_code, 'Sunday' week_day from dual
  union all
  select 'M', 'Monday' from dual
  union all
  select 'T', 'Tuesday' from dual
  union all
  select 'W', 'Wednesday' from dual
  union all
  select 'R', 'Thursday' from dual
  union all
  select 'F', 'Friday' from dual
  union all
  select 'S', 'Saturday' from dual
  )
  
  
  
  select a.ssrmeet_crn crn
        ,case b.dotw_code
         when 'U'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_begin_time, 'MM/DD/YYYY HH24:MI:SS'),'SUN')
         when 'M'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_begin_time, 'MM/DD/YYYY HH24:MI:SS'),'MON')
         when 'T'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_begin_time, 'MM/DD/YYYY HH24:MI:SS'),'TUE')
         when 'W'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_begin_time, 'MM/DD/YYYY HH24:MI:SS'),'WED')
         when 'R'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_begin_time, 'MM/DD/YYYY HH24:MI:SS'),'THU')
         when 'F'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_begin_time, 'MM/DD/YYYY HH24:MI:SS'),'FRI')
         when 'S'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_begin_time, 'MM/DD/YYYY HH24:MI:SS'),'SAT')
         end start_date
        ,case b.dotw_code
         when 'U'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_end_time, 'MM/DD/YYYY HH24:MI:SS'),'SUN')
         when 'M'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_end_time, 'MM/DD/YYYY HH24:MI:SS'),'MON')
         when 'T'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_end_time, 'MM/DD/YYYY HH24:MI:SS'),'TUE')
         when 'W'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_end_time, 'MM/DD/YYYY HH24:MI:SS'),'WED')
         when 'R'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_end_time, 'MM/DD/YYYY HH24:MI:SS'),'THU')
         when 'F'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_end_time, 'MM/DD/YYYY HH24:MI:SS'),'FRI')
         when 'S'
         then
         next_day(to_date(to_char(ssrmeet_start_date, 'MM/DD/YYYY') || ' ' || ssrmeet_end_time, 'MM/DD/YYYY HH24:MI:SS'),'SAT')
         end end_date
  from   ssrmeet a
         left join data_prep b
            on a.ssrmeet_sun_day = b.dotw_code
            or a.ssrmeet_mon_day = b.dotw_code
            or a.ssrmeet_tue_day = b.dotw_code
            or a.ssrmeet_wed_day = b.dotw_code
            or a.ssrmeet_thu_day = b.dotw_code
            or a.ssrmeet_fri_day = b.dotw_code
            or a.ssrmeet_sat_day = b.dotw_code
  where  ssrmeet_term_code = 201730
  and    ssrmeet_crn = 32789
  </code></pre>
  
  <p>If anyone could help out or even give me pointers on how to properly format my question on the forums I'd greatly appreciate it.</p>