I want to make a smart count operation, so that if the data in columns are the same, then it will be counted as 1.
My table is:
dbo.Messages
(
FromUserId INT,
ToUserId INT
)
Data:
INSERT dbo.Messages VALUES(1, 5), (2, 20), (5, 1), (1, 5);
The count should return 2 because (1,5) and (5,1) is the same in my algorithm.
How can I write it in SQL Server TSQL?
Thanks in advance.