- SQL
SELECT * FROM ( SELECT * , r = ROW_NUMBER() OVER ( PARTITION BY MobilePhone ORDER BY MobilePhone ) FROM dbo.v_candidates ) t WHERE t.r = 1
- LINQ
class Student { public string Name { get; set; } public int Score { get; set; } } List<Student> students = new List<Student>{ new Student {Name="Terry", Score=50}, new Student {Name="Tom", Score=85}, new Student {Name="Wade", Score=90}, new Student {Name="James", Score=70}, new Student {Name="Kobe", Score=90}, new Student {Name="AK", Score=90} }; var query = from student in students orderby student.Score descending, student.Name select student; var model=query.Where(m=>m.Name=='Tom').FirstOrDefault(); if(model!=null){ //数据处理 }