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 |
|
palak
Yak Posting Veteran
55 Posts |
Posted - 2008-10-07 : 10:41:46
|
| Hi,i have few columns in output and one of them is Quantiy column i want the '$' sign added to all values but if Quantity =0 then no signexampleItems Itemdesc Quantity---------------------------1 ASDFA 522 t54645 53 sawe 04 aswwr 30i want like:Items Itemdesc Quantity---------------------------1 ASDFA $522 t54645 $53 sawe 04 aswwr $30so select items, itemdesc, case when quantity = 0 then quantity else '......' end as quantityfrom itemstabwhat condition will come in else part Thanks for ur help. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-07 : 10:45:19
|
| Where do you want to show formatted values?MadhivananFailing to plan is Planning to fail |
 |
|
|
palak
Yak Posting Veteran
55 Posts |
Posted - 2008-10-07 : 10:52:14
|
| Thanks for replying.i want formatted values in output in Quantity column. in temstab table there are so many quantity values in this column and i want '$' sign only those values which is not 0.thanks |
 |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2008-10-07 : 10:53:58
|
| select items, itemdesc,CASE when [Quantity] <> '0' then '$' + [Quantity] else [Quantity] end as [Quantity]from itemstab |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-07 : 10:59:09
|
quote: Originally posted by darkdusky select items, itemdesc,CASE when [Quantity] <> '0' then '$' + [Quantity] else [Quantity] end as [Quantity]from itemstab
You should convert Quantity to varchar to append $MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-07 : 11:01:03
|
quote: Originally posted by palak Thanks for replying.i want formatted values in output in Quantity column. in temstab table there are so many quantity values in this column and i want '$' sign only those values which is not 0.thanks
If you use front end application, do this formation thereMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|