Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can i have my sql show the sum of 2 tables at the same time?
    text
    copied!<p>I've tried to show the result of sum of bill total and vat total (that customer paid VAT) and the sum of all(bill_total + vat) for monthly. However, my sql command show nothing after it executed. So could you kindly please help me as my sql knowledge was so limit.</p> <p>My tables are below</p> <p><strong>tbl_bill_total</strong></p> <pre><code>bill_id | bill_total | cust_id | showndate 1 | 1000 | 12 | 12/10/13 2 | 1200 | 13 | 1/11/13 3 | 500 | 12 | 3/11/13 </code></pre> <p><strong>tbl_vat_bill_total</strong></p> <pre><code>vat_id | vat_total | if_paid| showndate | cust_id 1 | 400 | false | 13/10/13 | 14 2 | 500 | true | 14/11/13 | 12 3 | 100 | false | 15/11/13 | 11 4 | 200 | true | 20/11/13 | 12 </code></pre> <p>The expected result should be like this</p> <pre><code>bill_total | vat_total | Sum_of_all | month 1000 | 0 | 1000 | 10 1700 | 700 | 2400 | 11 </code></pre> <p>Thank you very much</p> <p>** sorry I've changed the expected result… As it is a yearly report, so the outcome should list all sales in one year. <em>*</em></p> <p>below is my attempt that failed...</p> <pre><code>SELECT Sum(tbl_bill_total.bill_total) AS bill_totalOfSum, Sum(tbl_vat_bill_total.vat_total) AS vat_totalOfSum, tbl_vat_bill_total.if_paid, Month([tbl_bill_total.showndate]) AS month1 FROM tbl_bill_total INNER JOIN tbl_vat_bill_total ON tbl_bill_total.cust_id = tbl_vat_bill_total.cust_id GROUP BY tbl_vat_bill_total.if_paid, Month([tbl_bill_total.showndate]) HAVING (((tbl_vat_bill_total.if_paid)=True)); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload