Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Amanda wants to buy a car. Her budget is limited, and she has decided that she would prefer to spend it on a car that

image text in transcribedimage text in transcribed

Amanda wants to buy a car. Her budget is limited, and she has decided that she would prefer to spend it on a car that was produced recently. Her other option is to buy an older, used car, but she would not want to spend much money on such a vehicle. Help her choose all possible options, knowing that she can spend at most 50,000 on a new car produced in 2018 or later; or at most 20,000 on a used car produced in 2010 or later. You are given a non-empty table, cars, whose structure is described by the following query: create table cars ( id integer not null PRIMARY KEY, condition varchar(10) not null, year integer not nul, price integer not null ); Each row of the table cars contains information about a car: unique id (id), condition (condition), year of production (year) and price (price). Condition contains either one of two possible words: New or Used. Write an SQL query that returns a table consisting of one column (id), containing the ids of all the cars that fulfil Amanda's criteria. Rows should be ordered by increasing id. 1. Given the following data: cars: ---- id | condition | year | price ---+ 12 New 2018 30000 10 | Used 2007 13000 9 Used 2015 10000 1 New 2015 21000 7 Used 2015 23000 5 | Used 2012 12000 6 | New 2019 150000 your query should return the following table: id 5 9 12 2. Given the following data: cars: id | condition year | price --- 6 9 New | 2018 | 50000 4 New 2015 10000 6 New 2019 120000 1 | Used | 2010 | 20000 8 | New | 2008 | 22000 your query should return the following table: id 1 9

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

More Books

Students also viewed these Databases questions