[英]How write a query in SQL Server 2000?
I have 2 databases with the same tables and views, one in SQL Server 2008 and another in SQL Server 2000. 我有2个具有相同表和视图的数据库,一个在SQL Server 2008中,另一个在SQL Server 2000中。
I wrote this query and it works in SQL Server 2008, but it didn't work in SQL Server 2000. 我编写了此查询,该查询在SQL Server 2008中有效,但在SQL Server 2000中却无效。
How can I change my code to work in SQL Server 2000 ? 如何更改代码以在SQL Server 2000中工作?
SELECT
SUM(NA_DA) OVER (PARTITION BY vd.SI_VoucherH) AS a,
SUM(NA_CA) OVER (PARTITION BY vd.SI_VoucherH) AS b
FROM
acc.ACC_VOUCHERH vh
INNER JOIN
acc.Acc_VoucherD vd ON vh.SI_VoucherH = vd.SI_VoucherH
It's hard to say w/o knowing which table NA_DA & NA_CA are coming from or knowing which table has SI_VoucherH as it PK and which has it a FK. 很难说不知道哪个表NA_DA和NA_CA来自或知道哪个表的PK为SI_VoucherH,哪个表为FK。
Hopefully the following will get you close... 希望以下内容能使您接近...
SELECT
vda.NA_DA,
vda.NA_CA
FROM
acc.ACC_VOUCHERH vh
JOIN (
select
vd.SI_VoucherH,
NA_DA = Sum(vd.NA_DA),
NA_CA = SUM(NA_CA)
FROM
acc.Acc_VoucherD vd
GROUP BY
vd.SI_VoucherH
) vda
on vh.SI_VoucherH=vda.SI_VoucherH;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.