Palak Shah
Well-known member
- Joined
- Apr 29, 2020
- Messages
- 97
- Programming Experience
- 1-3
Hello folks,
I have prepared one query, but I feel this can be even more optimised! But I'm not sure what can be done
Query
Can someone please help
I have prepared one query, but I feel this can be even more optimised! But I'm not sure what can be done
Query
SQL:
SELECT
TOP 10 *
FROM
(
SELECT
co.orderid,
co.orderStatusId,
co.paymenttransactionstatusid,
(
SELECT
Count(IdProductSelect)
FROM
orderproductselect ops
WHERE
ops.orderid = co.orderid
AND co.orderstatusid IN (2, 9)
AND ops.quantity - ops.splitquantity > 1
) AS LineItemsCount
FROM
ci_orders co
) AS temp
WHERE
lineitemscount > 1
AND paymenttransactionstatusid = 1
AND orderid NOT IN (
SELECT
orderid
FROM
ordersplit
)
AND orderid Not IN (
SELECT
ChildOrderId
FROM
ordersplit
)
ORDER BY
LineItemsCount
Can someone please help
Last edited by a moderator: