Hello,
I'm having a problem getting my SQL code to work on MS SQL, when using the DISTINCT option.
I want to offer people the ability to sort the data by various fields which are not included in the selection or order by.
In mySQL this works, however MS SQL keeps erroring with...
But if I add it to the group by clause it then errors with..
How do I get MS SQL to work the same way mySQL does when trying to order using columns not in the selection?
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
I'm having a problem getting my SQL code to work on MS SQL, when using the DISTINCT option.
I want to offer people the ability to sort the data by various fields which are not included in the selection or order by.
In mySQL this works, however MS SQL keeps erroring with...
Column "myColumn" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
But if I add it to the group by clause it then errors with..
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
How do I get MS SQL to work the same way mySQL does when trying to order using columns not in the selection?
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!