我有一张表 [tblFull1 04WoodsideTransportV335],所有数据都来自该表。我想获得应力为 Max、Min 或 Abs 的 [Data Location] 和 [load_case]。它适用于 Max 和 Min。但由于某种原因,它不适用于 Abs。它在 ms Access 2013 中运行。我使用 vba 以编程方式生成查询。
Abs 和 max, min 运算符之间有什么区别使其无法正常工作吗?
当 Abs 查询运行时,由于某种原因它会宣传“As Expr1”,为什么要这样做?
我知道 SQL 看起来很糟糕,但它可以工作。如果您对如何改进它有任何建议,请告诉我。
对不起我的英语不好,我是挪威人。
带 MAX 函数的 SQL:
SELECT DISTINCT
t1.[load_case], t2.[Data Location] AS Nodenr,
t2.[MaxOfHoop Stress N/mm^2]
FROM
[tblFull1 04WoodsideTransportV335] AS t1,
(SELECT
[tblFull1 04WoodsideTransportV335].[Data Location],
MAX([tblFull1 04WoodsideTransportV335].[Hoop Stress N/mm^2]) AS [MaxOfHoop Stress N/mm^2]
FROM
[tblFull1 04WoodsideTransportV335]
GROUP BY
[tblFull1 04WoodsideTransportV335].[Data Location]
HAVING ((([tblFull1 04WoodsideTransportV335].[Data Location])
In (SELECT [Data Location]
FROM [tblFull1 04WoodsideTransportV335]
GROUP BY [Data Location]
HAVING Count(*) > 1))
AND ((MAX([tblFull1 04WoodsideTransportV335].[Hoop Stress N/mm^2])) Is Not Null))
ORDER BY
[tblFull1 04WoodsideTransportV335].[Data Location]) AS t2
WHERE
((t1.[Hoop Stress N/mm^2]) = [t2].[MaxOfHoop Stress N/mm^2])
ORDER BY
t1.[load_case] DESC;
带 Abs 函数的 SQL:
SELECT DISTINCT
t1.load_case, t2.[Data Location] AS Nodenr,
t2.[AbsOfHoop Stress N/mm^2] AS Expr1
FROM
[tblFull1 04WoodsideTransportV335] AS t1,
(SELECT
[tblFull1 04WoodsideTransportV335].[Data Location],
ABS([tblFull1 04WoodsideTransportV335].[Hoop Stress N/mm^2]) AS[AbsOfHoop Stress N/mm^2]
FROM [tblFull1 04WoodsideTransportV335]
GROUP BY [tblFull1 04WoodsideTransportV335].[Data Location]
HAVING ((([tblFull1 04WoodsideTransportV335].[Data Location])
In (SELECT [Data Location]
FROM [tblFull1 04WoodsideTransportV335]
GROUP BY [Data Location]
HAVING Count(*) > 1))
AND ((ABS([tblFull1 04WoodsideTransportV335].[Hoop Stress N/mm^2])) Is Not Null))
ORDER BY
[tblFull1 04WoodsideTransportV335].[Data Location]) AS t2
WHERE
(((t1.[Hoop Stress N/mm^2])=[t2].[AbsOfHoop Stress N/mm^2]))
ORDER BY
t1.load_case DESC;