how can i set the alias of column`s sum value based on another column in same table in sql?
<p>I have a table of <code>Accounts</code>, having columns:</p>

<p><code>Acc_Id</code>, <code>Transaction_TypeId</code>, <code>Amount</code></p>

<p>I want to get result as When <code>Transaction_TypeId = 1</code> then Sum of Amount as 'Total Advance Payments'. </p>

<p>Else when <code>Transaction_typeId = 2</code> then Sum of Amount as 'Total Reciepts'</p>

<p>Here is my SQL query:</p>

<pre><code>SELECT SUM(Amount) AS 'Sum' , Transaction_TypeId INTO #temp1  FROM AccountDetailTable WHERE  Account_MasterId = 1 GROUP BY Transaction_TypeId

SELECT Sum as 'Total Advance' from #temp1  WHERE #temp1.Transaction_TypeId = 1;
SELECT Sum as 'Total Cash Receipts' FROM #temp1  WHERE #temp1.Transaction_TypeId = 2;

DROP TABLE #temp1;
</code></pre>

<p>but this query returns me two different result sets. How can i get the values in same result sets?</p>