Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q5] What is the most preferred vehicle make in each state? Hint: Use the window function RANK() to rank based on the count of customers

Q5] What is the most preferred vehicle make in each state?

Hint: Use the window function RANK() to rank based on the count of customers for each state and vehicle maker.

After ranking, take the vehicle maker whose rank is 1.*/ I need proper sql query for this statement that can b valid in MYSQL and please refer the image i have attached

image text in transcribed
image text in transcribed
New wheels Data Dictionary shipper_id: Unique ID of the Shipper shipper_name: Name of the shipper shipper_contact_detai1s: Contact detai1 of the shipper product_id: Unique ID of the Product vehicle_maker: vehicle Manufacturing company name vehicle_mode 1: Vehicle model name vehicle_color: color of the vehicle vehicle_mode1_year: Year of Manufacturing vehicle_price: Price of the vehicle quantity: ordered Quantity customer_id: Unique ID of the customer customer_name: Name of the customer gender: Gender of the customer job_title: Job Title of the customer phone_number: Contact detai1 of the customer emai1_address: Email address of the customer city: Residing city of the customer country: Residing country of the customer state: Residing state of the customer customer_address: Address of the customer order_date: Date on which customer ordered the vehicle order_id: Unique ID of the order ship_date: Shipment Date ship-mode: Shipping Mode/class shipping: shipping ways posta1_code: Postan code of the customer discount: Discount given to the customer for the particular order by credit card in percentage credit_card_type: credit Card Type credit card number: Credit card number customer_feedback: Feedback of the customer quarter_number : Quarter Number You can refer to the following approach for question 5 1. Join product_t, order_t and customer_t in the mentioned order 2. Select state, vehicle_maker, take count of customer_d and then use Rank function using customer_id 3. Use the above query inside from statement and then filter where rank is 1 4. Apply proper indentation in the code You can refer to the following sample code for this

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_2

Step: 3

blur-text-image_3

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

Question

Write formal proposal requests.

Answered: 1 week ago

Question

Write an effective news release.

Answered: 1 week ago

Question

Identify the different types of proposals.

Answered: 1 week ago