What does order by 1, 2, 3, 4 stand for?
Sort by ordinal positions of columns
SQL Server allows you to sort the result set based on the ordinal positions of columns that appear in the select list.
The following statement sorts the customers by first name and last name. But instead of specifying the column names explicitly, it uses the ordinal positions of the columns:
SELECT
first_name,
last_name
FROM
sales.customers
ORDER BY
1,
2;
In this example, 1 means the first_name column and 2 means the last_name column.
Using the ordinal positions of columns in the ORDER BY clause is considered as bad programming practice for a couple of reasons.
Therefore, it is a good practice to always specify the column names explicitly in the ORDER BY clause.
For more details, go Here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With