0

I am using MS SQL Server Version 2008 and MariaDB 10.5.

My table and data :

enter image description here

Following is the query i am running on both the databases.

 select distinct distributor from market order by city

Found this query is failing in MS SQL Server database with error

SQL Error [145] [S0001]: ORDER BY items must appear in the select list if SELECT DISTINCT is specified. Understood the reason why it failing Reason for - ORDER BY items must appear in the select list if SELECT DISTINCT is specified

when i ran the same query run with MariaDB it ran successful without any error and gave me below output.

enter image description here

So i have doubt why MariaDB is behave different here? ideally it should fail right? Thanks in advance.

Developer
  • 150
  • 2
  • 12

1 Answers1

0

Please try this query

Select distinct col from ( Select col from table order by col )