SELECT all the newest record distinct keyword with a non null value in one column

前端 未结 1 1500
我在风中等你
我在风中等你 2021-01-15 16:01

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 | keywor         


        
1条回答
  •  -上瘾入骨i
    2021-01-15 16:17

    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
    

    0 讨论(0)
提交回复
热议问题