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)
 want to display "Amt" in Million's format.

Author  Topic 

frank.svs
Constraint Violating Yak Guru

368 Posts

Posted - 2007-02-08 : 01:02:39
Hi pals,

There is a small requirement. I need to display the amt values in million's format.
What could be the SELECT stmt for it.



create table test
(
amt numeric
)

insert into test values(100000000)
insert into test values(10000000)
insert into test values(1000000)
insert into test values(100000)

I need the output as follows
100,000,000
10,000,000
1,000,000
100,000


Any solution.
Thanks in advance.
Regards,
franky

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-08 : 01:07:48
[code]select convert(varchar(14),convert(money, amt),1) from test[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-02-08 : 07:45:56
You'll need to chop off the 2 decimal places with that CONVERT style I think.

Kristen
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-08 : 08:05:32
Decimal places chopped off:

select replace(convert(varchar(14),convert(money, amt),1), '.00', '') from test



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-02-08 : 08:12:15
Pity there isn't a LeftAllBut() function!
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-08 : 08:19:38
quote:
Originally posted by Kristen

Pity there isn't a LeftAllBut() function!



May be intentionally to prevent beginners from doing more string-manipulation in Back-End rather than Front-End !

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -