0

我有这个查询:

SELECT 
[QUERY1].[py],
[QUERY1].[al],
[QUERY1].[ga],
[QUERY1].[sy],
[QUERY1].[pl]
FROM [tab-Sample] as QUERY1, [tab-Sample]
WHERE [tab-Sample].[py] = [QUERY1].[py] AND
[tab-Sample].[al] <> [QUERY1].[al] 

我想写一个查询,jsut 计算这个结果,我找不到在哪里插入 Count(*) 也尝试过 Over() 但我无法管理这个。

4

1 回答 1

0

将所有内容包装为FROM. 但是,请确保将其命名为 ( Total)。

COUNT (*) AS Amount FROM
(
SELECT 
[QUERY1].[py],
[QUERY1].[al],
[QUERY1].[ga],
[QUERY1].[sy],
[QUERY1].[pl]
FROM [tab-Sample] as QUERY1, [tab-Sample]
WHERE [tab-Sample].[py] = [QUERY1].[py] AND
[tab-Sample].[al] <> [QUERY1].[al] 
) Total
于 2013-10-02T01:00:07.360 回答