SQL Server 2008: TOP 10 and distinct together

后端 未结 13 1569
刺人心
刺人心 2021-02-04 23:41

As the title says, I\'m using SQL Server 2008. Apologies if this question is very basic. I\'ve only been using SQL for a few days. Right now I have the following query:

13条回答
  •  余生分开走
    2021-02-05 00:06

    This is the right answer and you can find 3 heights value from table

    SELECT TOP(1)  T.id FROM (SELECT DISTINCT TOP(3) st.id  FROM Table1 AS t1 , Table2 AS t2 WHERE t1.id=t2.id ORDER BY (t2.id) DESC ) T ORDER BY(T.id) ASC
    

提交回复
热议问题