Hi
I have 3 tables
- bl_main containing two columns bl_id and bl_area
bl_id is unique here.
- bl_details containing two columns bl_id, name
bl_id is uniue again.
- bl_data containing 4 columns bl_id, month, paper_tons, bottles_tons
bl_id is not unique here. There will be multiple rows of same bu_id.
I am trying to retrieve data in the following way
bl_id | name | bl_area | sum(paper_tons) | sum (bottles_tons) | paper_tons | bottles_tons
sum(paper_tons) should return the sum of all the paper tons for the same bu_id like Jan to December.
Also all the bu_ids from bl_main must be retrieved even though no corresponding bu_id is present in bl_data. In this case the sum should be shown as 0.
I have not written complex sql queries before, please help me out!
Thanks in advance!