SQL从Access

时间:2017-05-24 13:23:27

标签: sql ms-access

我有两个不同的表,每个表包含一个值。例如:

    table1               table2

|Hours_worked|        |Work_Completed|
     250                    346

我希望我的查询从Work_completed中减去Hours_worked。我试过这个:

SELECT (SELECT Hours_worked FROM table1)- (SELECT Work_Completed FROM table2) AS Diff

我收到错误:"查询输入必须包含至少一个表或查询"

任何帮助都会很棒,谢谢

2 个答案:

答案 0 :(得分:2)

我认为这只会是:

select Hours_worked - Work_Completed as diff
from table1, table2

答案 1 :(得分:0)

只需添加FROM dual,我的意思是:

 SELECT 
 (SELECT Hours_worked FROM table1) - (SELECT Work_Completed FROM table2) AS Diff
 FROM DUAL