title: SQL Query to get column values that correspond with MAX value of another column?
body: <p>Ok, this is my query:</p>
  
  <pre><code>SELECT
    video_category,
    video_url,
    video_date,
    video_title,
    short_description,
    MAX(video_id) 
  FROM
    videos
  GROUP BY
    video_category
  </code></pre>
  
  <p>When it pulls the data, I get the correct row for the video_id, but it pulls the first row for each category for the others. So when I get the max result for the video_id of category 1, I get the max ID, but the first row in the table for the url, date, title, and description.</p>
  
  <p>How can I have it pull the other columns that correspond with the max ID result?</p>
  
  <p><strong>Edit: Fixed.</strong></p>
  
  <pre><code>SELECT
      *
  FROM
      videos
  WHERE
      video_id IN
      (
          SELECT
              DISTINCT
              MAX(video_id)
          FROM
              videos
          GROUP BY
              video_category
      ) 
  ORDER BY
      video_category ASC
  </code></pre>