Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- co.clientId AS clientId,
- co.createTime AS orderDate,
- cop.clientOrderId AS orderId,
- cop.id AS orderPositionId,
- cop.count AS quantityOrder,
- coph.statusId AS statusId,
- osps.name AS statusName,
- sum(coph.changeCount) AS quantityStatus
- FROM
- ClientOrder co
- JOIN ClientOrderPosition cop
- ON co.id = cop.clientOrderId
- JOIN ClientOrderPositionHistory coph
- ON cop.id = coph.clientOrderPositionId AND
- coph.statusId IN (3, 4)
- JOIN OrderSubPositionStatus osps
- ON coph.statusId = osps.id
- WHERE
- co.createTime > '2019-01-01 00:00:00'
- AND co.createTime < '2019-01-23 00:00:00'
- GROUP BY
- cop.id ASC,
- coph.statusId ASC
- HAVING
- quantitystatus > 0
- ORDER BY
- orderDate ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement