使用內聯后,unitid有重復記錄,選取AutoReplyId的最大值。
select b.*,c.ArticlesData from? (select UnitId,max(AutoReplyId) as AutoReplyId from WxGenerateQrScan a where UnitId in (1,2,3,4,5) and System=6 group by UnitId) b inner join WxAutoReplyMessage c on b.AutoReplyId = c.Id