title: SELECT DISTINCT on two columns, with multiple columns returned
body: <p>I am using the below query </p>
  
  <pre><code>SELECT TIMESTAMP,substr(DBNAME,1,10) as DBNAME, MSGSEVERITY as SEV, MSGNUM, substr(MSG,1,80) as MSG_trunc FROM TABLE ( PD_GET_LOG_MSGS( CURRENT_TIMESTAMP - 30 DAYS)) AS T WHERE MSGSEVERITY NOT IN 'I'  ORDER BY TIMESTAMP
  </code></pre>
  
  <p>Below is the output</p>
  
  <pre><code>TIMESTAMP                  DBNAME     SEV MSGNUM      MSG_TRUNC
  -------------------------- ---------- --- ----------- ---------------------------------------------------
  2019-11-17-05.45.33.266795 ABC        W          1602 ADM1602W  Rollforward recovery has been initiated.
  
  2019-11-17-05.45.39.086945 XYZ        W          1602 ADM1602W  Rollforward recovery has been initiated.
  
  2019-11-17-05.45.42.960668 ABC        W          1602 ADM1602W  Rollforward recovery has been initiated.
  
  2019-11-17-05.45.48.287948 XYZ        W          1602 ADM1602W  Rollforward recovery has been initiated.
  
  2019-11-17-07.04.09.038759 ABC        W          1611 ADM1611W  The rollforward recovery phase has been completed.
  
  2019-11-17-07.04.14.688757 XYZ        W          1611 ADM1611W  The rollforward recovery phase has been completed.
  
  2019-11-17-07.04.18.339282 XYZ        W          1611 ADM1611W  The rollforward recovery phase has been completed.
  </code></pre>
  
  <p>Can I get the output with distinct DBNAME and MSGNUM</p>
  
  <p>The output should be as below</p>
  
  <pre><code>TIMESTAMP                  DBNAME     SEV MSGNUM      MSG_TRUNC
  -------------------------- ---------- --- ----------- ---------------------------------------------------
  2019-11-17-05.45.33.266795 ABC        W          1602 ADM1602W  Rollforward recovery has been initiated.
  
  2019-11-17-05.45.39.086945 XYZ        W          1602 ADM1602W  Rollforward recovery has been initiated.
  
  2019-11-17-07.04.09.038759 ABC        W          1611 ADM1611W  The rollforward recovery phase has been completed.
  
  2019-11-17-07.04.14.688757 XYZ        W          1611 ADM1611W  The rollforward recovery phase has been completed.
  </code></pre>