我有一個表[tblFull1 04WoodsideTransportV335],所有的數據來自。我想獲得壓力爲Max,Min或Abs的[Data Location]和[load_case]。它適用於Max和Min。 但由於某些原因,它不適用於Abs。它在ms Access 2013中運行。我使用vba以編程方式生成查詢。爲什麼我的sql在使用Max函數時不能與Abs函數一起工作?
Abs和max,min運算符之間是否有任何區別,使得它不起作用?
當Abs查詢運行時,由於某種原因,它將「As Expr1」廣告,爲什麼會這樣做?
我知道SQL看起來不好,但它的工作原理。如果您對如何改進建議有任何建議,請告訴我。
對不起,我英語不好,我是挪威語。
SQL與MAX功能:
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;
SQL有ABS功能:
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;
ABS是不是分組功能,ABS(1,2- ,3,4,5)沒有意義,而最大(1,2,3,4,5)= 5 –
當你的組(根據'數據位置')有多個值的箍應力,其中'abs( )'你想回來嗎? – shawnt00