zoukankan      html  css  js  c++  java
  • 解决union不能order by问题

    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
  • 相关阅读:
    231. Power of Two
    204. Count Primes
    205. Isomorphic Strings
    203. Remove Linked List Elements
    179. Largest Number
    922. Sort Array By Parity II
    350. Intersection of Two Arrays II
    242. Valid Anagram
    164. Maximum Gap
    147. Insertion Sort List
  • 原文地址:https://www.cnblogs.com/maoyu417/p/1133903.html
Copyright © 2011-2022 走看看