I have below queries
WITH Recent_BankAccountNumber_CTE (BankAccountNumber, TransactionId) AS
(
SELECT TOP 25 BankAccountNumber, TransactionId
FROM [Transaction]
WHERE CustomerId = 1234
ORDER BY TransactionId DESC
)
SELECT
BankAccountNumber, TransactionId
FROM
Recent_BankAccountNumber_CTE
ORDER BY
OutboundTransactionId DESC
I get this output:
BankAccountNumber OutboundTransactionId
------------------------------------------
8002950781 32078
8002950781 32077
8002950781 32076
016200270000486 32075
121054658698 32074
035200146349621 32073
200300019256 32072
200300019256 32071
200300019256 32070
200300019256 31088
018021030517 31087
102957612131 31086
100336018793 31085
100336018793 31084
042033430297001 31083
042033430297001 31082
100336018793 31081
8004062604 31080
102957612131 31079
042033430297001 31078
121054658698 31077
111353490614 31076
121054658698 31075
82455039 31074
110854031395 31073
What I am after is
As soon as I do (instead of above )
SELECT DISTINCT TOP 10 (BankAccountNumber)
FROM Recent_BankAccountNumber_CTE
I get below, which is incorrect
BankAccountNumber
-----------------
016200270000486
018021030517
035200146349621
042033430297001
100336018793
102957612131
110854031395
111353490614
121054658698
200300019256
Can someone please let me know what is wrong with DISTINCT TOP 10?
