title: RFM Analysis - Value keeps changing
body: <p>Got the following query going.</p>
  
  <pre><code>SELECT
      customer_id,
      NTILE(5) OVER (ORDER BY MAX(oms_order_date)) AS r_score
  FROM 
      mdwh.us_raw.l_dmw_order_report
  WHERE 
      quantity_ordered &gt; 0
      AND customer_id IS NOT NULL
      AND customer_id != ('')
      AND UPPER(line_status) NOT IN ('','RETURN', 'CANCELLED')
      AND UPPER(item_description_1) NOT IN ('','FREIGHT', 'RETURN LABEL FEE', 'VISIBLE STITCH')
      AND (quantity_ordered * unit_price_amount) &gt; 0
      AND extended_amount &lt; 1000 --NO BULK ORDERS
      AND oms_order_date BETWEEN '2020-01-01' AND '2020-01-01'
      AND SUBSTRING(upc,1,6) IN (SELECT item_code FROM item_master_zs WHERE new_division BETWEEN '11' AND '39')
  GROUP BY
      customer_id
  ORDER BY
      customer_id
  </code></pre>
  
  <p>All I'm doing here is, given some conditions, to give me the unique customer ID, then cluster their latest purchase date into quintiles and provide me with a score in the second column. But everytime I run the query, the r_score value keeps changing? What am I doing wrong..? Here's a snippet of what the table looks like (again, r_score value keeps changing):</p>
  
  <p><a href="https://i.stack.imgur.com/ltA1k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ltA1k.png" alt="enter image description here"></a></p>