我需要在查询1中显示[Data From Query 2 Should Go Here]
的插槽中输入查询2的结果。我目前只是单独运行两个查询并手动输入#,但是可以将所有这些作为一个查询运行?
--Query 1
Select
case
when employee Like 'Ricardo%' Then '38526'
when employee Like 'James%' Then '44187'
else employee
end As [Employee],
COUNT(CASE WHEN d.shipped_status IN ('Hold', 'Waiting Approval') THEN d.ID else null end) As [Processing],
Count(CASE WHEN d.shipped_status = 'Shipped' THEN d.ID ELSE NULL END) As [Shipped],
Count(CASE WHEN d.shipped_status = 'Pending' THEN d.ID ELSE NULL END) As [Pending],
--This is where the Secondary Query Should Go
'' As [Data From Query 2 Should Go Here]
FROM employeeSales
WHERE d.employee IS NOT NULL
GROUP BY
case
when employee Like 'Ricardo%' Then '38526'
when employee Like 'James%' Then '44187'
else employee
end
--Query 2
SELECT
case
when employee Like 'Ricardo%' Then '38526'
when employee Like 'James%' Then '44187'
else employee
end As [Employee],
COUNT(CASE WHEN b.ItemCode = '1400' THEN D.ID ELSE NULL END)
+
COUNT(CASE WHEN a.shipped_status = 'Out Of Stock' THEN a.ID ELSE NULL END)
FROM
inventory a
INNER JOIN itemsordered b
ON a.ID = b.ID
GROUP BY
case
when employee Like 'Ricardo%' Then '38526'
when employee Like 'James%' Then '44187'
else employee
end As [Employee]