我如何组合这两个查询,所以结果是一行包含两列,其中包含返回值。我正在努力使其与外部应用一起使用。
谢谢
SELECT
COUNT(P.new_propid) as ProposedToCredit
FROM new_prop P
OUTER APPLY
(
SELECT TOP 1 createdon FROM New_proposalstatusupdate PSU
WHERE PSU.new_propstatusupdateid = P.New_propId AND PSU.New_action = 2 ORDER BY PSU.CreatedOn ASC
) PSU
WHERE CAST(PSU.CreatedOn as date) = CAST(GETDATE() as date)
SELECT
COUNT(P.new_propid) as ProposedToFunder
FROM new_prop P
OUTER APPLY
(
SELECT TOP 1 createdon FROM New_proposalstatusupdate PSU
WHERE PSU.new_propstatusupdateid = P.New_propId AND PSU.New_action = 3 ORDER BY PSU.CreatedOn ASC
) PSU
WHERE CAST(PSU.CreatedOn as date) = CAST(GETDATE() as date)