title: How to build one query of two group in two table? I want to get result for same that original results
body: <p>How to build one query of two group in two table? </p>
  
  <p><strong>TABLE A</strong></p>
  
  <pre><code>ID  NAME
  1   BBB
  2   CCC
  3   DDD
  4   EEE
  </code></pre>
  
  <p><strong>TABLE B</strong></p>
  
  <pre><code>ID  (TABLE A).ID   VISIT   CPC  
  1      2            1      0.26
  2      2            1      0.26
  3      2            1      0.28
  4      2            1      0.28
  5      2            1      0.30
  6      1            1      0.75
  7      1            1      0.75
  8      1            1      0.75
  9      1            1      0.20
  10     1            1      0.20
  11     4            1      0.80
  12     4            1      0.80
  13     4            1      0.40
  14     4            1      0.40
  15     4            1      0.40
  16     3            1      1.15
  17     3            1      1.15
  18     3            1      1.25
  19     3            1      1.25
  20     3            1      1.35
  
  **Original Results**
  
  
  
  NAME  TOTAL VISIT   TOTAL COST ( SUM(VISIT) * CPC )
  
  BBB    5            1.38
  CCC    5            2.65
  DDD    5            2.8
  EEE    5            6.15
  </code></pre>
  
  <p><strong>First getting results for group by TABLE A.ID and then GROUP BY CPC in TABLE B.</strong>
   Make only one query </p>
  
  <p>Just reply for this matters</p>