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
Step: 1
In the provided SQL code sql SELECT Neighbourhood AVGprice FR...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Introduction to Emergency Management
Authors: Michael K. Lindell, Carla Prater, Ronald W. Perry
1st edition
471772606, 471772607, 9781118311516, 1118311515, 978-0471772606
Students also viewed these Abstract Writing questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App