SQL Server - order by clause depends on (field-list, type) pair
Query, for example "Query-1":
select THIS_FIELD, THAT_FIELD, THAT_COUNT
from THE_TABLE
order by THIS_FIELD
works fine when THIS_FIELD
has a type String
. however, "Query-2" is below:
select THIS_FIELD, THAT_FIELD, THAT_COUNT, *
from THE_TABLE
order by THIS_FIELD
gives me an error Ambiguous column name
to occur
THIS_FIELD
in a select clause when it
THIS_FIELD
is of type String
and works fine when THIS_FIELD
here is an integer.
How can I get around this?
TIA.
+3
source to share