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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 '$' sign in output

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 sign

example

Items Itemdesc Quantity
---------------------------
1 ASDFA 52
2 t54645 5
3 sawe 0
4 aswwr 30

i want like:

Items Itemdesc Quantity
---------------------------
1 ASDFA $52
2 t54645 $5
3 sawe 0
4 aswwr $30

so select items, itemdesc, case when quantity = 0 then quantity
else '......'
end as quantity
from itemstab
what 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?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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
Go to Top of Page

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
Go to Top of Page

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 $

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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 there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -