I have two tables Received and Issued , they are related with ID field. I have tried to use the following query to get the result and it works only when both tables have values. however when one tables is empty the query is returning NULL value . I need help pls
SELECT
c.vaccine_id,
c.name,
SUM(QRecived-IsuedQuan) Quantity
FROM
vaccine c
LEFT OUTER JOIN (
SELECT SUM(quantity_recieved) QRecived,vaccine_id from vaccine_detail group by vaccine_id
) a ON a.vaccine_id=c.vaccine_id
LEFT OUTER JOIN (
select SUM(issued_quantity) IsuedQuan,vaccine_id from issued_item group by vaccine_id
) b ON b.vaccine_id=a.vaccine_id "
GROUP BY c.vaccine_name,c.vaccine_id ";
NOTE: the above query is going to be run in SQLITE and this is just to inform you that SQLLITE does not supporting RIGHT & FULL JOINs