"SELECT DISTINCT" ignores different cases

The collation will be set to case insensitive.

You need to do something like this

Select distinct col1 COLLATE sql_latin1_general_cp1_cs_as
From dbo.myTable

Not sure about MS SQL but with MySQL or postgres, use BINARY for this operation. Cast the column to binary like so:

SELECT DISTINCT BINARY(column1) from table1;

Just change column1 and table1 as per your schema.

Full example that works for me in MySQL 5.7, should work for others:

SELECT DISTINCT BINARY(gateway) from transactions;

Cheers!


SELECT DISTINCT
   CasedTheColumn 
FROM
   (
   SELECT TheColumn COLLATE LATIN1_GENERAL_BIN AS CasedTheColumn
   FROM myTAble
   )FOO
WHERE
   CasedTheColumn IN ('A', 'a'...)