Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We want to know which electric vehicles have made the most year - on - year improvement in electric range. Write a query using common

We want to know which electric vehicles have made the most year-on-
year improvement in electric range. Write a query using common table ex-
pressions to return the vehicles (make, model) that made the most single year
improvement to their electric range. Output just the top 10 largest year-on-
year improvements. The output table should have at least seven columns (extra
ev_wa
Columns (14)
id
vin
county
city
state
postal_code
model_year
make
model
ev_type
cafv_eligibilit.
electric_range
base_msrp
census_tractcolumns are okay): make, model, year1, year2, range1(range in year1), range2
(range in year2), and diff (difference in the range between the two years).
Note: A single year improvement is made between adjacent years, e.g., the
improvement between 2022 and 2023. Hypothetically, if Toyota Rav4s had an
electric range of 50 in 2022 and 60 in 2023, the year-on-year improvement would
be 10. If the range were 60 in 2022 and 50 in 2023, the year-on-year improvement
would be -10(not an improvement at all).
Hint: This query should build upon your previous query. If you are having
difficulty with the previous query, you can still get partial credit on this problem
by writing the rest of the query assuming your query from problem 1 is correct.
Next, we want to know whether there is a relationship between median household
income and prevalence of electric cars. We will use census tract as a minimum geo-
graphic unit. Median household income per census tract can be found in the income
table, with each tract identified by the census geo ID. This geo ID maps to the census
tracts in the ev_wa table.
However, the census tract identifier from the ev_wa table takes a different form than
the census_geo_id from the income table. You will need a new function SUBSTRING
to join the two tables in this database on census tract. The following example query
joins these two columns together by taking a substring of census_geo_id and match-
ing it against census_tract. A few rows of the resulting join are provided for reference.
SELECT e.census_tract, i.census_geo_id
FROM ev_wa e
JOIN income i ON SUBSTRING(i.census_geo_id,8)= e.census_tract
LIMIT 5;
census_tract | census_geo_id
--------------+--------------------
08005006861|14000US08005006861
53029971302|14000US53029971302
06031980000|14000US06031980000
06073018509|14000US06073018509
06001423200|14000US06001423200
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

User Defined Tensor Data Analysis

Authors: Bin Dong ,Kesheng Wu ,Suren Byna

1st Edition

3030707490, 978-3030707491

More Books

Students also viewed these Databases questions