Question: In the code below, what do the 1 in GROUP BY and 2 in ORDER BY mean? SELECT Neighbourhood, AVG(price) FROM table GROUP BY 1
In the code below, what do the 1 in GROUP BY and 2 in ORDER BY mean?
SELECT Neighbourhood, AVG(price)
FROM table
GROUP BY 1
ORDER BY 2 DESC;
Numbers are not valid at that position, and this code would result in a syntax error. | ||
They are telling SQL to group 1st and sort 2nd. | ||
1 and 2 are column names in the source table. | ||
They are referencing the column numbers, i.e. GROUP BY 1 = GROUP BY Neighbourhood, and ORDER BY 2 = ORDER BY AVG(Price) |
Step by Step Solution
There are 3 Steps involved in it
In the provided SQL code sql SELECT Neighbourhood AVGprice FR... View full answer
Get step-by-step solutions from verified subject matter experts
