title: What does "DISTINCT ON (expression)" do?
body: <p>I understand how <code>DISTINCT</code> works, but I don't understand <code>DISTINCT ON (expression)</code>.</p>
  
  <p>Take the first example from this screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/rxRBh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rxRBh.png" alt="enter image description here"></a></p>
  
  <p>How does the <code>(a % 2)</code> part affect everything? Is it saying that if <code>a % 2</code> evaluates to true, then return it, then continue doing so for all other tuples but only return if the returned value is distinct?</p>