本文介绍了如何组合两个选择语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT COUNT(j.JobID) as OrderCount1
From tbl_pms_JobOrders j
Inner Join tbl_pms_JobOrders_Trucks_Info jt on jt.JobID = j.JobID
Inner Join tbl_pms_DeliveryInfo d on d.JobID = jt.JobID
where jt.StausCode != 1 and jt.StausCode != 77
and j.WarehouseID = 225
--date
and jt.truckid= 310
and jt.JobID not in (select JobID from tbl_pms_POD_Submit)
and d.recno in (select max (recno) from tbl_pms_DeliveryInfo
where JobID in ( select JobID from tbl_pms_JobOrders_Trucks_Info where TruckID=310
and JobID in (select JobID from tbl_pms_JobOrders where WarehouseID=225))
Group by JobID)
==================================================================
SELECT COUNT(j.JobID) as OrderCount2
From tbl_pms_JobOrders j
Inner Join tbl_pms_JobOrders_Trucks_Info jt on jt.JobID = j.JobID
Inner Join tbl_pms_DeliveryInfo d on d.JobID = jt.JobID
where jt.StausCode != 1 and jt.StausCode != 77
and j.WarehouseID = 225
--date
and jt.truckid= 310
and jt.JobID in (select JobID from tbl_pms_POD_Submit)
and d.recno in (select max (recno) from tbl_pms_DeliveryInfo
where JobID in ( select JobID from tbl_pms_JobOrders_Trucks_Info where TruckID=310
and JobID in (select JobID from tbl_pms_JobOrders where WarehouseID=225))
Group by JobID)
推荐答案
SELECT
*
FROM
(SELECT ks, COUNT(*) FROM TableName GROUP BY ks) t1
INNER JOIN
(SELECT ks, COUNT(*) FROM TableName WHERE Age > Palt GROUP BY ks) t2
ON t1.ks = t2.ks
或
===
使用UNION,
OR
===
use UNION like,
SELECT ks, COUNT(*) FROM Table GROUP BY ks
UNION
SELECT ks, COUNT(*) FROM Table WHERE Age > Palt GROUP BY ks
这篇关于如何组合两个选择语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!