Support ongoing development - donate to help us maintain and improve the platform. 🖥️ Support sqltest →
SQL code copied to buffer
Task 55:

Customer Store Preference

MySQL
Analyze customer rental data to determine each customer's preferred store based on the ratio of rentals at each branch.
Store affiliation is determined through the employee (field store_id in the staff table) who processed the rental. A preferred store is one where the number of rentals is at least 1.25 times greater than at another store.
The output table should contain the following columns:
- customer_id: Unique identifier for the customer.
- preferred_store_id: Identifier of the preferred store (1, 2, or NULL if no preference exists).

Sort the results by the customer_id column in ascending order.
Expected result Columns: 2 · Rows: 599
customer_id preferred_store_id

Sample rows open after wrong checks: 0 of 3

Write your query below and click "Check it!". Tables are described in the right pane.

The query result will appear here. Ctrl+Enter - Run query

Hi! Could we please enable some services and cookies to improve your experience and our website?

Privacy & Cookie Policy.