2012-10-09 68 views
0

我有這個查詢寫入Access數據庫。如何爲絕對數字的值包含此SQL子查詢?

queryText = "SELECT Technicians.ID, firstName, lastName, Technicians.[Zone], 
COUNT(technicianAssignedId) AS JobsDone, 
MAX(Faults.timeCompleted) AS LastJobTime, 
MIN(Technicians.[Zone] - & faultZone &) AS Distance ' MIN has no use 
FROM Technicians LEFT OUTER JOIN Faults ON 
Technicians.ID = Faults.technicianAssignedID 
WHERE Specialization = '" & specialization & "' 
`AND Availability = 'available' 
GROUP BY Technicians.ID, firstName, lastName, Availability,` Technicians.[Zone], Specialization 
ORDER BY 7 DESC" 

我這得到絕對值

SELECT CASE 
WHEN value < 0 THEN value * -1 
ELSE number *1 END 
AS VALUE 
FROM DB; 

現在,隨着距離的別名列,最終可能,我需要使用(* 1)爲正爲負數,但我可以」弄清楚如何把它放在一起。

感謝所有幫助

+4

爲什麼不使用ABS(值)函數? – JamieSee

回答

5

嘗試

ABS(Technicians.[Zone] - & faultZone &) AS Distance 

ABS doc

+0

廢話,我試過發佈前,它沒有工作,我以爲ABS()不accces工作,但現在是工作... – johnyTee

1

ABS()適用於所有SQL版本