title: how to select distinct records in oracle?
body: <p>I want to select distinct rows on some condition but when i am adding id column in select statement it returns all the rows???</p>
  
  <p>the below query is working fine</p>
  
  <pre><code>select distinct dst_bnk_acnt_id
  ,dst_cust_id
  ,org_cust_id
  ,dst_pos_id
  ,pmt_typ_cd 
  from tb_cm_t_pmt_coll
  where org_pos_id = 8 OR dst_pos_id = 8 OR dst_bnk_acnt_id = 1 ;
  </code></pre>
  
  <p>but when i want to select a latest record using order by id(desc) it returns all rows!</p>
  
  <pre><code>SELECT  distinct id
  ,dst_bnk_acnt_id
  ,dst_cust_id
  ,org_cust_id
  ,dst_pos_id
  ,pmt_typ_cd  
  FROM  tb_cm_t_pmt_coll
  WHERE org_pos_id = 8 OR dst_pos_id = 8 OR dst_bnk_acnt_id = 1 
  ORDER BY id DESC;
  </code></pre>
  
  <p>i know 'id' column is primary key  and all its values are unique and because of this all rows becomes unique.</p>
  
  <p>i want to select a distinct row using these <strong><code>[dst_bnk_acnt_id,dst_cust_id,org_cust_id,dst_pos_id,pmt_typ_cd]</code></strong> columns only but i also want to order them using id in descending order.</p>
  
  <p>please help.</p>