title: SQL total up certain element in a column to create another column
body: <p>I'm not sure the title for this question, i just want to achieve something like below, if there is already an answer, please kindly provide me the link or provide the search tag, so i got a direction to what i'm looking for.</p>
  
  <p>I have a table like below,<br>
  Table 1<br>
  date       |payname |type|amount|ID<br>
  2017/07/01 |Cash    | c  |100   | A1<br>
  2017/07/01 |Cash    | c  |200   | A1<br>
  2017/07/01 |USD     | f  |200   | A1<br>
  2017/07/01 |SGD     | f  |100   | A1<br>
  2017/07/01 |USD     | f  |100   | A1<br>
  2017/07/01 |Yen     | f  |200   | A1<br>
  2017/07/02 |USD     | f  |200   | A1<br>
  2017/07/02 |SGD     | f  |400   | A1<br>
  2017/07/02 |WON     | f  |300   | A1<br>
  2017/07/02 |Cash    | c  |100   | A1<br>
  2017/07/02 |Cash    | c  |300   | A1<br>
  2017/07/02 |Cash    | c  |200   | A1  </p>
  
  <p>TAble 2<br>
  date       |C.Cards|ID<br>
  2017/07/01 |100         | A1<br>
  2017/07/01 |200         | A1<br>
  2017/07/01 |300         | A1<br>
  2017/07/01 |100         | A1<br>
  2017/07/01 |200         | A1<br>
  2017/07/01 |300         | A1<br>
  2017/07/02 |100         | A1<br>
  2017/07/02 |100         | A1<br>
  2017/07/02 |200         | A1<br>
  2017/07/02 |100         | A1<br>
  2017/07/02 |200         | A1<br>
  2017/07/02 |100         | A1  </p>
  
  <p>Expected Result<br>
  date       |Cash|Cash-Forex|C.Cards<br>
  2017/07/01 |300 | 600      | 1200<br>
  2017/07/02 |600 | 900      | 800  </p>
  
  <p>Expected result table<br>
  1. Date column, grouped by of table 1 &amp; 2 date column<br>
  2. cash column, sum of table 1 type of 'c'<br>
  3. cash-forex column, sum of table type of 'f'<br>
  4. c.cards column, sum of table 2 c.cards column  </p>
  
  <p>I'm able to generate expected result table, date &amp; cash &amp; cash-forex column, but when i try to join table to generate c.cards column, i can't find the expected answer....please help me guys, thanks!</p>