我想知道如何在 ASP Classic 中运行这个 MS SQL 查询并像在 MS SQL 中一样获得结果。
DECLARE @weeks int = 26
;WITH Person AS (
SELECT
datediff(ww, DATE_GIVEN, getdate())+1 AS Week,
AVG(CHECK_AMOUNT) AS Person_Check_Amount
FROM CHECKS
WHERE PERSON_NO=11 AND DATE_GIVEN >= dateadd(ww, -@weeks, getdate())
GROUP BY datediff(ww, DATE_GIVEN, getdate()) +1
)
, Company AS (
SELECT week,
AVG (COMPANY_Check_Amount) AS COMPANY_Check_Amount
FROM (
SELECT
datediff(ww, DATE_GIVEN, getdate())+1 AS Week,
SUM(CHECK_AMOUNT)/COUNT(DISTINCT PERSON_NO) AS COMPANY_Check_Amount
FROM CHECKS
WHERE PERSON_NO<>11 AND DATE_GIVEN >= dateadd(ww, -@weeks, getdate())
GROUP BY datediff(ww, DATE_GIVEN, getdate())+1
) t
GROUP BY Week
)
SELECT c.week
, isnull(Person_Check_Amount,0) Person_Check_Amount
, isnull(Company_Check_Amount,0) Company_Check_Amount
FROM Person p
FULL OUTER JOIN Company c ON c.week = p.week
ORDER BY Week DESC
然后我想循环这个并显示结果。
我认为它就像这样简单:dim strQuery =“ PUT ABOVE CODE HERE ”然后运行:objSchDeductions.Open strQuery 然后:while not objSchDeductions.EOF 并循环所有它直到没有更多但它不是出于某种原因工作。
请帮忙,谢谢...