Monday, August 10, 2026

169 ) 9 ) query to find the customer who ordered more than 5 orders

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

9 ) query to find the customer who ordered more than 5 orders 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




To find customers with more than 5 sales orders using just the sales_order table, you can group directly by the customer identifier within that table.

Here is the SQL query: 



 SELECT   c.customer_id,
         c.customername,
         Count(s.order_id) AS total_orders
FROM     sales_order S
JOIN     customer c
ON       s.customerid = c.customerid
GROUP BY customer_id
HAVING   Count(order_id) > 5;

    No comments:

    Post a Comment

    239 ) Metadata Management

    Metadata Management and Modern Data Governance Tools Metadata management forms the backbone of data governance, data lineage, and data quali...