Take the number of the numbers: first by the number of sorts, then take the first
SELECT * FROM
(
Select A.billid,a.demandvoltage,count (1) as RecordCount,
Row_number () over (PARTITION by billID ORDER by Count (1) DESC) as SN
From etl_singlecharging201805 A with (NOLOCK)
WHERE RowKey like ' 00000058-bca0-4559-8f8f-2fc3b61eb01c% '
OR Rowkey like ' 000001b7-3e26-47fd-9a67-b177750d5147% '
GROUP BY A.billid,a.demandvoltage
) b
WHERE b.billid in (' 00000058-bca0-4559-8f8f-2fc3b61eb01c ',
' 000001b7-3e26-47fd-9a67-b177750d5147 ') and B.sn=1
Sort by Number:
Select A.billid,a.demandvoltage,count (1) as RecordCount, Row_number () over (PARTITION by billID ORDER by Count (1) DESC) as SN
From etl_singlecharging201805 A with (NOLOCK)
WHERE RowKey like ' 00000058-bca0-4559-8f8f-2fc3b61eb01c% ' OR RowKey like ' 000001b7-3e26-47fd-9a67-b177750d5147% '
GROUP BY A.billid,a.demandvoltage
How to take the number of numbers in SQL Server