title: Simple sql string correction
body: <p>I have 2 tables in my sqlite3 database. Can someone help me with the sql command below:</p>
  
  <p><code>tbltrans</code>:</p>
  
  <pre><code>transid |  transdate | discountpercentage | Bank
  12345     10/09/2011     5                  20.00
  </code></pre>
  
  <p><code>tbltrans2</code>:</p>
  
  <pre><code>transid   |   itemnr   |price | btwpercentage | qty
  12345         205        10.11        12        5
  12345         302        15.00        6         7
  12345         501        20.00        21        3
  </code></pre>
  
  <p>My first question is:</p>
  
  <ol>
  <li><p>I want to get a query table with total amount of sale for each transid's and calculated cash, like:</p>
  
  <pre><code>Select
      Sum(tbltrans2.qty * tbltrans2.price) as TotalAmount,
      (Totalamount - tbltrans.Bank) as Cash
  where 
      tbltrans.transid = tbltrans2.transid 
      and transdate = '10/09/12'
  </code></pre>
  
  <p>Can someone please correct this SQL statement ?</p></li>
  </ol>
  
  <p><strong>-- This question below is already solved --</strong></p>
  
  <p>So, can anyone correct my sql code to work with this table layout:</p>
  
  <pre><code>select 
      sum(price * qty - (price * qty) * (tbltrans.discountpercentage / 100)  
  from 
      tbltrans2 
  where 
      btwpercentage = 6) as total6 ,
    sum(price * qty - (price*qty)*(tbltrans.discountpercentage /100) from tbltrans2 where btwpercentage =12) as total12,
  sum(price * qty - (price*qty)*(tbltrans.discountpercentage /100) from tbltrans2 where btwpercentage =21) as total21
   where transdate = date('10/09/2011')
  </code></pre>