title: Group By Not Working... What am I doing wrong?
body: <p>Been stuck on this for hours now. Right now, i am trying to group values for HR1 and HR2 in the same row by Submission_Id but Oracle is returning two separate entries entirely foir the same Submission ID and Response_Type. Instead of having all of the values for HR1 and HR2 grouped by Submission_Id and Response_type, it is returning two separate row; one each for HR1 and for HR2 even though the Submission_ID and Response_Type are the same. What am I doing wrong?</p>
  
  <p>For example, What I am getting is below:</p>
  
  <pre><code>Submission_Id   Posting_Type   Response_Type  Day_Of_Year    GMT_Offset    HR1         HR2
  2460037         Daily          UTC0           602014         5            08-03-18 13:02:17 
  2460037         Daily          UTC0           602014         5                       08-03-18 13:02:17
  2460037         Daily          UTC1           602014         5            08-03-18 13:02:17 
  2460037         Daily          UTC1           602014         5                       08-03-18 13:02:17
  </code></pre>
  
  <p>What I am trying to get is below:</p>
  
  <pre><code>Submission_Id   Posting_Type   Response_Type  Day_Of_Year    GMT_Offset       HR1                              HR2
  2460037         Daily          UTC0           602014         5            12-MAR-18 08-03-18 13:02:17      12-MAR-18 08-03-18 13:02:17
  2460037          Daily         UTC1           602014         5            12-MAR-18 08-03-18 13:02:17      12-MAR-18 08-03-18 13:02:17
  </code></pre>
  
  <p>The Query i've been finagling with is below:</p>
  
  <pre><code>select 
     s.submission_id
   , CASE WHEN FL.FORM_LINE_ID = '2001'
  THEN 'Same-Day'
  WHEN FL.FORM_LINE_ID = '2002'
  THEN 'Daily'
  END             Posting_Type
   , ff.form_field_tx     Response_Type
   , v.data_date          Day_Of_Year
   , v.utc_offset         GMT_Offset
   , v.create_dt          Posted_Date
   , CASE WHEN FF.FORM_FIELD_TX IN ('UTC0', 'UTC1', 'UTC2', 'UTCD') and v.HR_NUM = 1
      THEN to_char(v.HR, 'DD-MM-YY HH24:MI:SS')
      WHEN FF.FORM_FIELD_TX IN ('Tutoring', 'Studying') and v.HR_NUM = 1
      THEN Value_Tx
      END             HR1
   , CASE WHEN FF.FORM_FIELD_TX IN ('UTC0', 'UTC1', 'UTC2', 'UTCD') and v.HR_NUM = 2
      THEN to_char(v.HR, 'DD-MM-YY HH24:MI:SS')
      WHEN FF.FORM_FIELD_TX IN ('Time Reading', 'Time Working Out') and v.HR_NUM = 2
      THEN Value_Tx
      END             HR2
   from submission s
   inner join submission_value sv on s.submission_id = sv.submission_id
   inner join value v on  v.value_id = sv.value_id
   inner join form_field ff on sv.form_field_id = ff.form_field_id
   inner join form_line fl on ff.form_line_id = fl.form_line_id
   group by s.submission_id, ff.form_field_tx, v.data_date   , v.utc_offset, v.create_dt ;
  </code></pre>
  
  <p>Sample Data is as follows:</p>
  
  <pre><code>Submission:
   Submission_Id       Submission_Dt        Submission_Name          Create_Dt
   24600037            03-15-2018            20180315                11-MAR-18
  
  Submission_Value
   Submission_value_Id    Submission_ID     Value_ID            Form_Field_Id
    990                   24600037          5550                777
   991                   24600037          5551                777
    992                   24600037          5552                777
    993                   24600037          5553                777
  
  Form_Field
    Form_Field_Id      Form_Field_Tx       Create_DT           Form_Line_Id
    1001               UTC0                15-MAR-18           2001
    1002               UTC1                15-MAR-18           2001
  
  Form_line
  Form_Line_Id         Form_Line_Tx
    2001               Example1
    2002               Example2
  
  Value
   Value_Id     data_Date         HR        Value_Tx          HR_num
  
  Create Table Submission
  (
   Submission_Id varchar2(10)
  , Submission_Dt date
  , Submission_name varchar2(30)
  , Create_dt date
  );
  insert into Submission (Submission_id, Submission_Dt, Submission_Name,     Create_DT)
  Values('24600037', '03-15-2018', '20180315', '11-MAR-18)';
  
  Create Table Value
  (
    Value_Id number
  , value_tx varchar2(50)
  , hr_utc   varchar2(10)
  , utc_offset number
  , data_date varchar2(10)
  , hr       datetime
  , create_dt date
   );
  
   insert into value (Value_id, value_tx, hr_utc, utc_offset, data_date, hr,     create_dt,)
   values (5551, 'Test Value', 'UTC0', '4', '28-FEB-18 12.51.45.252000000 PM', sysdate);
  
   insert into value (Value_id, value_tx, hr_utc, utc_offset, data_date, hr, create_dt,)
   values (5552, 'Test Value', 'UTC1', '4', '28-FEB-18 12.51.45.252000000 PM', sysdate)  
   Create Table Submission_Value
   (
    Submission_value_Id   Number
   , Submission_id         Number
   , Value_Id              Number
   , Form_field_Id         Number
   );
   insert into Submission_Value (Submission_Value_Id, Submission_Id, Value_Id, Form_Field_Id)
   values('990', '24600037', '5550', '777');
  
  insert into Submission_Value (Submission_Value_Id, Submission_Id, Value_Id, Form_Field_Id)
   values('991', '24600037', '5551', '777');
  
  insert into Submission_Value (Submission_Value_Id, Submission_Id, Value_Id, Form_Field_Id)
   values('992', '24600037', '5552', '777');
  
  insert into Submission_Value (Submission_Value_Id, Submission_Id, Value_Id, Form_Field_Id)
   values('993', '24600037', '5553', '777');\
  Create Table Form_Field
  (
     Form_Field_Id      Number
   , Form_Field_Tx      Varchar2(200)
   , Create_DT          Date
   , Form_Line_Id       Number
  )
  insert into Form_Field (Form_Field_id, Form_Field_Tx, Create_Dt, Form_Line_ID)
  values('1001', 'UTC0', '15-MAR-18', '2001');
  insert into Form_Field (Form_Field_id, Form_Field_Tx, Create_Dt, Form_Line_ID)
  values('1002', 'UTC0', '15-MAR-18', '2001');
  Create Table Form_Line
  (
   Form_line_id         Number
  ,Form_line_tx         Varchar2(200)
  )
  
  insert into Form_Line (Form_Line_Id, Form_Line_Tx)
  values('2001', 'Example1');
  insert into Form_Line (Form_Line_Id, Form_Line_Tx)
  values('2002', 'Example2');
  </code></pre>