解决union不能order by问题

时间:2021-01-30 19:57:47
SELECT id, LEFT(Bbs_Title, 14) AS Bbs_Title, LEFT(User_name, 3)
      AS User_name, test1,test2,
      test3 = '内部论坛'
FROM (SELECT top 3 Bbs_MessageID AS id, LEFT(Bbs_Title, 14) AS Bbs_Title,
              LEFT(User_name, 3) AS User_name, Bbs_Message_date AS test1,
              ISTOP AS test2, test3 = '内部论坛'
        FROM Bbs_Message
        ORDER BY test2 desc,id DESC) a
UNION
SELECT id,  Bbs_Title,
               User_name, test1,  test2,
               test3 = '他山之十'
         FROM (SELECT top 3 ArticleID AS id, LEFT(Title, 14) AS Bbs_Title, LEFT(Editor, 3)
                       AS User_name, UpdateTime AS test1, ISzhiding AS test2,
                       test3 = '他山之十'
                 FROM Article
where FBLBID=''
                 ORDER BY test2 desc,id DESC) b