I know; lets more than one query exicute in studio management but does anyone know how to join these queries together so they run as one. below is a basic query but I would like to run about 5 of these together rather than create different reports for them. they all have different where clauses and have the same amount of columns each. Is there a way of doing this??
Cheers!
SELECT InspectionProcedureName AS Inspection, COUNT(*) AS Total
FROM UnitData_Vehicle
WHERE (DATEDIFF(day, InspectionDateTime, GETDATE()) = 1)
GROUP BY InspectionProcedureName
I would like to see
Inspection Total
qc 10
Inspection Total
photo 20
Inspection Total
insp 30
You can use union all to get one result set from your queries
SELECT InspectionProcedureName AS Inspection, COUNT(*) AS Total
FROM UnitData_Vehicle
WHERE (DATEDIFF(day, InspectionDateTime, GETDATE()) = 1)
GROUP BY InspectionProcedureName
UNION ALL
SELECT InspectionProcedureName AS Inspection, COUNT(*) AS Total
FROM AnotherTable
WHERE (DATEDIFF(day, InspectionDateTime, GETDATE()) = 1)
GROUP BY InspectionProcedureName
UNION ALL
-- Next query etc...
You can use UNION operation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.