I wasn’t aware that running DISTINCT in SQL Server would also return the results sorted. My manager at work mentioned this in passing, and I needed to verify this for myself. I came up with some test data:
DROP TABLE IF EXISTS dbo.TestTable;
CREATE TABLE dbo.TestTable(
TeamName varchar(30) NOT NULL
);
INSERT INTO dbo.TestTable VALUES ('Falcons');
INSERT INTO dbo.TestTable VALUES ('Saints');
INSERT INTO dbo.TestTable VALUES ('Bucs');
INSERT INTO dbo.TestTable VALUES ('Panthers');
INSERT INTO dbo.TestTable VALUES ('Colts');
INSERT INTO dbo.TestTable VALUES ('Bills');
INSERT INTO dbo.TestTable VALUES ('Falcons');
INSERT INTO dbo.TestTable VALUES ('Raiders');
INSERT INTO dbo.TestTable VALUES ('Panthers');
SELECT DISTINCT TeamName FROM dbo.TestTable;
Some duplicate records in there. After running the SELECT, I took a look at the execution plan:

A Distinct Sort. Thinking about this, it makes sense that the query engine would sort all of the input in order to figure out if there were duplicate records.
However, this isn’t the case in Postgres, you can’t rely on the DISTINCT results being sorted.