October 7, 2004 at 12:56 am
Data available in one column should display some values in one column and some values in 2nd colums
Ex:
Account Amount
Dr 5000
Cr 6000
Dr 4000
should display like this
Acct Dramt Cramt
Dr 5000 null
Cr null 6000
Dr 4000 null
October 7, 2004 at 1:48 am
SELECT
Account Acct,
Amount Dramt,
NULL Cramt
FROM [TableName]
WHERE Account = 'Dr'
UNION ALL
SELECT
Account Acct,
NULL Dramt,
Amount Cramt
FROM [TableName]
WHERE Account = 'Cr'
K. Brian Kelley
@kbriankelley
October 7, 2004 at 5:41 am
Select Account,
Case when Account = 'Cr' Then Amount Dramt ,
Case When Account = 'Dr' Then Amount Cramt
from [TableName ]
October 7, 2004 at 12:38 pm
October 13, 2004 at 11:44 pm
Thank you for giving reply,
but at the same time can we display sum of those values at the bottom.
like:
Acct Dramt Cramt
Dr 5000 null
Cr null 6000
Dr 4000 null
9000 6000
October 14, 2004 at 2:01 am
Select Account,
Case when Account = 'Cr' Then Amount End Dramt ,
Case When Account = 'Dr' Then Amount End Cramt
from [TableName ]
UNION
Select NULL Account,
SUM(Case when Account = 'Cr' Then Amount End ) Dramt ,
SUM(Case When Account = 'Dr' Then Amount End ) Cramt
from [TableName ]
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply