我需要得到 2 个汇总数字,但是我遇到了问题,因为一个是针对总订单的,一个是针对不完整的订单的。这些使用相同的初始查询,但是未完成的订单有一个额外的 where 子句。可以将这些放入查询中,以便我只获得 2 列。我以前做过内部查询,但我从来没有用 2 个不同的 where 子句做过一个?!任何想法都非常受欢迎
用于总订单的查询即时消息是:
SELECT Count(TBL_PROPERTY.PROPREF) AS TotalOrders
FROM TBL_PROPERTY INNER JOIN
TBL_REPAIR_ORDER ON TBL_PROPERTY.PROPREF = TBL_REPAIR_ORDER.PROPREF INNER JOIN
TBL_REPAIR_VISIT ON TBL_REPAIR_ORDER.ORDERID = TBL_REPAIR_VISIT.ORDERID INNER JOIN
tbl_contract ON tbl_repair_order.CONTRACT = tbl_contract.CONTRACT
WHERE (TBL_CONTRACT.CONTRACT IN ('STE')) AND
(TBL_REPAIR_ORDER.RAISEDDATE BETWEEN '01/12/2008' AND DATEADD(hh,23,'01/01/2009'))
使用订单不完整查询即时消息:
SELECT Count(TBL_PROPERTY.PROPREF) AS TotalOrders
FROM TBL_PROPERTY INNER JOIN
TBL_REPAIR_ORDER ON TBL_PROPERTY.PROPREF = TBL_REPAIR_ORDER.PROPREF INNER JOIN
TBL_REPAIR_VISIT ON TBL_REPAIR_ORDER.ORDERID = TBL_REPAIR_VISIT.ORDERID INNER JOIN
tbl_contract ON tbl_repair_order.CONTRACT = tbl_contract.CONTRACT
WHERE (TBL_CONTRACT.CONTRACT IN ('STE')) AND
(TBL_REPAIR_ORDER.RAISEDDATE BETWEEN '01/12/2008' AND DATEADD(hh,23,'01/01/2009')) AND
TBL_REPAIR_ORDER.STATUS <> 'Completed')