Sobes.tech
Middle+

1. Output the TOP 10 by total orders of users who made more than 2 orders in the last 30 days 2. Output the TOP 3 categories by revenue in the last 6 months.

sobes.tech AI

Answer from AI

To solve the task using SQL (for example, in PostgreSQL), you can write the following queries:

  1. Top 10 users by total order amount, who have made more than 2 orders in the last 30 days:
SELECT user_id, SUM(order_amount) AS total_amount
FROM orders
WHERE order_date >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY user_id
HAVING COUNT(order_id) > 2
ORDER BY total_amount DESC
LIMIT 10;
  1. Top 3 categories by revenue in the last 6 months:
SELECT category_id, SUM(order_amount) AS revenue
FROM orders
WHERE order_date >= CURRENT_DATE - INTERVAL '6 months'
GROUP BY category_id
ORDER BY revenue DESC
LIMIT 3;

If you need to implement this in Go, you typically write queries to the database and process the results using standard libraries like database/sql or ORM.

1. Output the TOP 10 by total orders of users who… - sobes.tech