Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Emergency Management

Authors: Michael K. Lindell, Carla Prater, Ronald W. Perry

1st edition

471772606, 471772607, 9781118311516, 1118311515, 978-0471772606

More Books

Students also viewed these Abstract Writing questions

Question

How does justifiable conduct differ from excusable conduct?

Answered: 1 week ago

Question

Define reaction criteria and learning criteria.

Answered: 1 week ago

Question

Explain the purpose of a recovery/mitigation committee.

Answered: 1 week ago