title: How to set a custom 'rank' order for MAX function in query?
body: <p>I have a dataset with duplicates that contains a 'status' integer field. I was wondering if there is some way to set the MAX() aggregate function to 'set' certain values to be lower priority.</p>
  
  <p>What I'm ultimately after is to run a query on this dataset to group the duplicates and pick the one with the 'max' status value that isn't '6' but return 6 if it is the value and there are no duplicate for this record.</p>
  
  <p>Is using MAX the best way to go about this or is there a better way?</p>