Click here to Skip to main content
15,991,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
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)
Posted
Comments
thatraja 25-Oct-13 3:09am    
UNION ALL?

1 solution

Try something like this :
-----------------------------

SQL
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


OR
===

use UNION like,

SQL
SELECT ks, COUNT(*) FROM Table GROUP BY ks
UNION
SELECT ks, COUNT(*) FROM Table WHERE Age > Palt GROUP BY ks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900