SQL query using WHERE IN clause

前端 未结 1 1184
借酒劲吻你
借酒劲吻你 2021-01-28 07:58

This might be simple but I\'m new to SQL and couldn\'t find how to do this exactly.

and I have following table:

相关标签:
1条回答
  • 2021-01-28 08:34

    I Postgres, I think distinct on does what you want:

    select distinct on (dim, frequency) s.*
    from sample_tbl s
    order by dim, frequency, date desc, version desc;
    

    For each dim/frequency combination this returns one row. That row is the first row encountered based on the order by clause.

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