I have this query:
SELECT a.total
, b.total
, (a.total - b.total) as dv
, a.customer_name
, a.report_date
, b.report_date
FROM topsourcesfcy a
CROSS
JOIN topsourcesfcy b
WHERE a.customer_name = b.customer_name
AND a.customer_name = 'SPECIALTY DRILLING FLUIDS LIMITED'
AND a.report_date = '2016-2-10'
AND b.report_date = '2016-2-9'
AND a.report_date! = b.report_date
but the problem is sometimes the record might exist in a
and not in b
or in b
and not in a
, which will cause the query to execute to false but I still want to select it if it exists in only one or both.
Thanks.