Question
· Sep 5, 2019

Ambiguous sort column error

Hello,

I have a small SQL question.  

Running an example queries in our Samples Namespace: 

1. select top 5 Description,Category from Cinema.Film order by Category - runs fine no issues and returns 2 columns as expected

2. select top 5 * from Cinema.Film order by Category - runs fine no issues and returns 8 columns as expected

3. select top 5 Description,Category,* from Cinema.Film order by ID - runs fine no issues, and returns 10 columns, with my first 2 repeated

4. When I try to combine the first 2 queries: 

select top 5 Description,Category,* from Cinema.Film order by Category

I get an error:

Ambiguous sort column: CATEGORY^ SELECT TOP ? Description , Category , * FROM Cinema . Film ORDER BY Category

I assume there is a simple explanation and it's not critical, but I would love to understand what is the issue. I kind of expect to get the similar 10 columns with my first 2 columns of my Description and Category repeated twice, but ordered by Category, similar to example #3.

Thank you

Discussion (4)3
Log in or sign up to continue