title: What is best way to write query with multiple aggregate columns and multiple where clause
body: <p>I have a table <strong>tbl_LEDGER</strong> </p>
  
  <pre><code>+-----------+--------+-----+
  | AccountId | GlCode | Amt |
  +-----------+--------+-----+
  | LAS00001  | INTRAC | 100 |
  | LAS00002  | INTRAC | 150 |
  | LAS00001  | INTLAS | 200 |
  +-----------+--------+-----+
  </code></pre>
  
  <p><strong>Desired Result :</strong></p>
  
  <pre><code>+-----------+------------+-----------+
  | AccountId | intractamt | intlasAmt |
  +-----------+------------+-----------+
  | LAS00001  |        100 |       200 |
  | LAS00002  |        150 |         0 |
  +-----------+------------+-----------+
  </code></pre>
  
  <p><strong>Here is my working query:</strong></p>
  
  <pre><code>select accountid,sum(amt) intracamt,  (select SUM(amt)  from tbl_LEDGER 
  where   GLCode='intlas' and AccountID=intrac.AccountID ) intlasamt 
  from tbl_LEDGER intrac 
  where GLCode='intrac'    group by AccountID    order by AccountID
  </code></pre>
  
  <p><strong>Another Working query :</strong> </p>
  
  <pre><code>select a.accountId,a.amt as 'RACAMT',b.amt as 'LACAMT' from 
  (
  select accountid ,glcode, SUM(amt) as amt from nbfcledger where GLCode='intrac' group by GLCode,AccountID 
  ) a
  inner join 
  (
  select accountid ,glcode, SUM(amt) as amt from nbfcledger where GLCode='intlas'  group by GLCode,AccountID 
  )b
  on a.AccountID = b.AccountID order by AccountID
  </code></pre>
  
  <p>What are the other ways in which I can achieve the same result? Which one is best and why? I was hoping I could do this without PIVOT. </p>