Reputation: 1336
I have two different tables that contain one value each. For example:
table1 table2
|Hours_worked| |Work_Completed|
250 346
I want my query to subtract Hours_worked from Work_completed. I tried this:
SELECT (SELECT Hours_worked FROM table1)- (SELECT Work_Completed FROM table2) AS Diff
I get the error: "Query input must contain at least one table or query"
Any help would be great, thanks
Upvotes: 0
Views: 1664
Reputation: 660
Just add FROM dual, i mean:
SELECT
(SELECT Hours_worked FROM table1) - (SELECT Work_Completed FROM table2) AS Diff
FROM DUAL
Upvotes: 0
Reputation: 15968
I think it would just be:
select Hours_worked - Work_Completed as diff
from table1, table2
Upvotes: 2