Postman collection
Customers Read

pixiEmillControlCustomers

Returns customers whose number of orders with order lines in status ANG or recent AUS reaches a minimum count, optionally filtered by shop.

Lists customers who have several qualifying orders, for example to spot duplicate or suspicious orders by the same customer.

Steps:

  1. An empty ShopID is treated as NULL, which means no shop filter.
  2. An order qualifies if at least one of its lines in Orderlines meets either condition:
    • status ANG, regardless of date, or
    • status AUS and OrderDate less than DayRange days ago, measured as calendar-day difference to today.
  3. Qualifying orders in OrderHeader are joined to Customers via CustRef = CustKey.
  4. If ShopID is set, only customers whose CustomerOf equals ShopID are included.
  5. Results are grouped per customer (CustRef). Only customers with at least MinOrderCount qualifying orders are returned.

Each row contains the customer's name, e-mail address, number of qualifying orders and shop. The result has no explicit sort order.

Notes

  • All tables are read with NOLOCK. Results may include uncommitted data.
  • Because of SQL operator precedence (AND before OR), the DayRange restriction applies only to lines in status AUS. Orders with ANG lines are counted no matter how old they are.
  • The code does not show which table the unqualified OrderDate column belongs to. If Orderlines has no such column, the order date from OrderHeader is used.
  • The shop filter uses the customer's shop (CustomerOf), not the shop of the order.
  • Name, eMail and ShopID are built with MAX() per customer group.

Tables used

Customers · Read OrderHeader · Read Orderlines · Read
SQL object:
dbo.pipiEmillControlCustomers
Updated at 2026-10-30