title: Max function in multiple tables
body: <p>Cannot get the maximum value of state per project
  The only I get is all states from one to last, in the list. that output</p>
  <pre><code>| idState  | idProject |
  | -------- | -------------- |
  | 1        | 1              |
  | 2        | 1              |
  | 3        | 1              |
  | 4        | 1              |
  | 1        | 2              |
  | 2        | 2              |
  </code></pre>
  <p>and so on.
  What I need is</p>
  <pre><code>| idState  | idProject |
  | -------- | -------------- |
  | 4        | 1              |
  | 2        | 2              |
  </code></pre>
  <p>Where State is the maximum value from the column per project</p>
  <pre><code>SELECT e.idState, e.delivery, ep.idProject
  FROM State e
  CROSS JOIN StatexProject ep ON e.idState = ep.idState
  WHERE ep.idProject = (SELECT MAX(exp.idState) FROM StatexProject exp
  WHERE ep.idState = exp.idState);
  </code></pre>