sql server 查询表某个字段不重复数据

1
2
3
4
5
6
7
8
9
10
SELECT TOP (500) ID, Personname, Personcode, Telphone, Fraction
into temp3
FROM Records AS a
WHERE (LEN(Personcode) = 18 OR
      LEN(Personcode) = 15) AND (NOT EXISTS
          (SELECT 1 AS Expr1
         FROM Records
         WHERE (Personname = a.Personname) AND (Fraction > a.Fraction) OR
               (Personname = a.Personname) AND (Fraction = a.Fraction) AND (ID < a.ID)))
ORDER BY Fraction DESC

  

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。