write a sql query to divide suppliers into 5 equal buckets basis order contribution for…
- User
write a sql query to divide suppliers into 5 equal buckets basis order contribution for the month.
- Assistant
To divide suppliers into 5 equal buckets based on their order contribution for the month, you can use the following query:
codeWITH ordered_suppliers AS ( SELECT * FROM suppliers WHERE order_date >= DATEADD(month, -1, GETDATE()) ) SELECT (ROW_NUMBER() OVER (ORDER BY SUM(value) DESC) - 1) / 5 AS bucket, name, SUM(value) AS total_value FROM ordered_suppliers GROUP BY name
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.