title: sum two different table and the subtract its total
body: <p>i have this problem with me on how to sum total value from two different table and then after getting its total i want to subtract it. for example i have table "rsales" and "sales" and i have these ff vlue below.</p>
  
  <p>data from "rsales"</p>
  
  <pre><code>id | total | pcode |
  1  | 100   | 2143  |
  2  | 100   | 2143  |
  3  | 50    | 2222  |
  4  | 50    | 2222  |
  </code></pre>
  
  <p>data from "sales"</p>
  
  <pre><code>id | total | pcode |
  7  | 100   | 2143  |
  8  | 50    | 2222  |
  </code></pre>
  
  <p>my problem is this. i want to sum all "total" values from sales and sum "total"value from rsales group by pcode.and then after getting its sum i want to subtract it. my page  must be something like this.</p>
  
  <pre><code>   total    pcode
   | 100    | 2143  |
   | 50     | 2222  |
  </code></pre>
  
  <p>i have this ff code but it doesnt wor for me</p>
  
  <pre><code>sql "select sum(rsales.total)- sum(sales.total) as t1 where pcode = rsales.pcode"
  </code></pre>