解决方案 »

  1.   

    select a.id,a.title,a.iphone ,a.agentid,a.startdate from(
    select *,row_number() over(partition by agentid order by startdate desc) as rId from info 
    ) as a where a.rId<=3
      

  2.   

      SELECT a.id,
             a.title,
             a.iphone,
             a.agentid,
             a.startdate
        FROM (SELECT *,
                     ROW_NUMBER() OVER (PARTITION BY agentid
                                        ORDER BY startdate DESC
                     ) n
                FROM info
               WHERE hide_flag = 1
             ) a
       WHERE n <= 3
    ORDER BY agentid, n