我有一個查詢,我已簡化並寫在下面。 如何顯示計算爲2個獨立內聯選擇語句的2個字段的時差?計算從2個獨立的行內選擇語句中提取的值
SELECT x.name ,
(SELECT data.ts
FROM data
WHERE prim_key = x.prim_key and roll_no ='1'
) **starttime** ,
(SELECT data.ts
FROM woman_data
WHERE prim_key = x.prim_key and roll_no ='10'
) **endtime**
, **TIME_TO_SEC(TIMEDIFF(endtime , starttime)** as timediff // This line does not work.It cannot recognize endtime ans starttime
FROM data x
INNER JOIN y
ON x.prim_key = y.prim_key
ORDER BY x.prim_key
謝謝..工作對我來說非常好。 – user1606540