有如下表格。如果最大confidenceCode值是唯一的,则返回该行,否则为否。
LocationID ConfidenceCode
017755029 05
017755029 05
017755029 01
018577655 05
018577655 09
021886301 10
021886301 09
021886301 09
预期产出
LocationID ConfidenceCode
018577655 09
021886301 10
我的SQL如下,它正在工作,寻找更好的版本
;WITH CTEConfidenceCode as
(
SELECT *, dense_rank() over (partition by LocationID order by
[ConfidenceCode] desc) as ConfidenceRowNum FROM testTable
),
CTEGroup as
(SELECT DUNS1,[ConfidenceCode],count(1) countValue FROM CTEConfidenceCode
WHERE ConfidenceRowNum=1
GROUP BY LocationID,[ConfidenceCode])
SELECT * FROM CTEGroup WHERE countValue=1
答案 0 :(得分:1)
[HttpPost]
[Route("Send")]
public HttpResponseMessage Send(MessageDetails details)
{
}
public class MessageDetails
{
public string usernameTo { get; set; }
public string message { get; set; }
}