Get nearest records to specific date grouped by type

前端 未结 1 1198
一整个雨季
一整个雨季 2020-12-21 11:02

I\'m sorry I can\'t be more specific, but I don\'t know how to describe my problem in the title.. respectively I don\'t know how to search for similar question.

So h

相关标签:
1条回答
  • 2020-12-21 11:36

    Right now I can only think of a subselect version:

    SELECT type, amount
    FROM table AS t
    WHERE dat = (
        SELECT MAX(dat)
        FROM table
        WHERE type=t.type
            AND dat <= '2011-03-01'
    )
    
    0 讨论(0)
提交回复
热议问题