Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
eugz
Posting Yak Master
210 Posts |
Posted - 2013-04-04 : 20:37:16
|
I have four fields Status, PaidAmount, AdjustAmount, WriteOff. Based on this data I populate ListView. The result looks like:----------------------------------------------------Status..........PaidAmount......AdjustAmount......WriteOffPaid................$1500Adjustment................................$150WriteOff.......................................................130----------------------------------------------------I would like combine PaidAmount and AdjustmentAmount in new column, for instance, Amount to get result like:----------------------------------------------------Status.........AmountPaid..............$1500Adjustment......$150WriteOff..........$130----------------------------------------------------If is it possible how it to do?Thanks. |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2013-04-04 : 21:14:41
|
create table #t1 (status varchar(10), PaidAmount money, AdjustmentAmount money, Writeoff money)insert into #t1 VALUES ('Paid', 1500, null, null)insert into #t1 VALUES ('Adjustment', null, 150, null)insert into #t1 VALUES ('WriteOff', null, null, 130)GOSELECT status, COALESCE(PaidAmount, AdjustmentAmount, WriteOff) AmountFROM #t1GO DROP Table #t1-Chad |
|
|
|
|
|
|
|