title: SQL query - credit , debit , balance
body: <p>DISCLAIMER : <strong>I Know this has been asked numerous times, but all I want is an alternative.</strong></p>
  
  <p>The table is as below :</p>
  
  <pre><code>create table 
  Account
  (Name varchar(20),
   TType varchar(5),
   Amount int);
  
  insert into Account Values
  ('abc' ,'c', 500),
   ('abc', 'c', 700),
   ('abc', 'd', 100),
   ('abc', 'd', 200),
  
  ('ab' ,'c', 300),
   ('ab', 'c', 700),
   ('ab', 'd', 200),
   ('ab', 'd', 200);
  </code></pre>
  
  <p>Expected result is simple:</p>
  
  <pre><code> Name     Balance
   ------  -----------
  ab         600
  abc        900
  </code></pre>
  
  <p>The query that worked is : </p>
  
  <pre><code>select Name, sum(case TType when 'c' then Amount
                      when 'd' then Amount * -1 end) as balance 
  from Account a1 
  group by Name.
  </code></pre>
  
  <p>All I want is, is there any query sans the 'case' statement (like subquery or self join ) for the same result?</p>