We have 2 very simple SELECT statements:
SELECT value from table where date between DATE1 and DATE2
SELECT value from table where date between DATE3 and DATE4
We need a way to write a single SQL statement which will get the difference of the “value” that is returned from these two SQL statements.
We tried the following but it was not successful:
SELECT value from table where date between DATE1 and DATE2
minus
SELECT value from table where date between DATE3 and DATE4
Any suggestion is highly appreciated.
Untested but should work:
Assuming that your
SELECT valueis guaranteed to return a single value