Skip to content Skip to sidebar Skip to footer

SELECT All The Newest Record Distinct Keyword With A Non Null Value In One Column

Following on from this question SELECT the newest record with a non null value in one column I know have a problem where I have this data id | keyword | count | date 1 | ipod | 200

Solution 1:

Use:

SELECT t.id,
       t.keyword,
       t.count,
       t.date
  FROM TABLE t
  JOIN (SELECT t.keyword,
               MAX(t.date) 'max_date'
          FROM TABLE t
         WHERE t.count IS NOT NULL
      GROUP BY t.keyword) x ON x.keyword = t.keyword
                           AND x.max_date = t.date

Post a Comment for "SELECT All The Newest Record Distinct Keyword With A Non Null Value In One Column"