title: BigQuery duplicated rank() numbers
body: <p>I have a transaction table with account_no, order_id, start_date, end_date and ranking. I am trying to rank the transactions based on their start date and end date. But the problem is all the transaction have similar start and end dates, i can't possible rank the transactions based on their date. </p>
  
  <p>My code</p>
  
  <pre><code>select distinct account_id,order_id,order_validfrom_date as start_date,order_validto_date as end_date, 
   rank() OVER (PARTITION BY account_id ORDER BY order_validfrom_date desc ,order_validto_date desc  ) AS ranking, 
  
  from  `datamart_dimsum.rpt_dly_dimsum_subscription_details` 
  
  where order_validfrom_date &lt;= '2020-01-14'  and  account_id in (216223
  )  order by account_id, order_id,order_validfrom_date,order_validto_date  
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>account_id | order_id |  start_date  | end_date   | ranking
    216223     482847      2017-10-09    2017-11-08      1
    216223     472121      2017-10-09    2017-11-08      1
    216223     312312      2017-10-09    2017-11-08      1
  </code></pre>
  
  <p>Is there any way to rank the first transaction as 1 despite same start date and end dates? I had tried the ROW_NUMBER() function but failed.</p>