Is it possible to sort a column name using a column name alias?
Not possible it gets error
Yes ,it is possibleselect top 5 ArticleId as id from tblarticlemaster order by id descselect top 5 ArticleId as id fromtblarticlemaster order by 1 descThis is the result of above query—id45174516451545144513
It is possible to sort a column using its alias in SQL Server. You can use the alias in the ORDER BY clause to specify the column to sort by.
SELECT column1 AS alias1, column2 AS alias2FROM table_nameORDER BY alias1;
SELECT column1 AS alias1, column2 AS alias2
FROM table_name
ORDER BY alias1;
Here we have two columns column1 and column2 from the table table_name. We have also given them aliases alias1 and alias2, respectively. We are then using the alias alias1 in the ORDER BY clause to sort the result set by the values in column1. When using an alias in the ORDER BY clause, you should use the same alias as the one you defined in the SELECT clause. If you use the original column name instead of the alias, the sorting will be done based on the original column name.
Yes