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 2008 Forums
 SQL Server Administration (2008)
 simple query with column alias - needs formatted

Author  Topic 

poetdi
Starting Member

2 Posts

Posted - 2011-09-22 : 20:55:15
Hello all from a NOOB. ;-)
I am creating a simple query like this:

select bktitle, slprice, slprice-slprice*.07 discount
from titles

This works quite well, however, the discount column created has the wrong format. The slprice column is in the format 49.00, but the discount has a generic format of 49.00000.

How can I format this column? THANK YOU for saving me banging my head against the wall.

Diane

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-09-22 : 21:28:26
use cast or convert


select bktitle, slprice, convert(decimal(10,2), slprice-slprice*.07 ) discount



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

poetdi
Starting Member

2 Posts

Posted - 2011-09-23 : 08:07:48
Oh, thank you so much for helping this noob!!! Worked perfectly. Have a great weekend!!!!
Go to Top of Page
   

- Advertisement -