As part of our daily operations and development, we need to determine the order count by order status to find out how many orders are in a particular status. By using the following query, we can obtain this information quickly in Hybris.
SELECT {status.code} AS status_code, COUNT({o.code}) AS order_count
FROM {Order AS o JOIN OrderStatus AS status ON {o.status} = {status.pk}} GROUP BY {status.code}