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
 General SQL Server Forums
 New to SQL Server Programming
 CAST

Author  Topic 

chipembele
Posting Yak Master

106 Posts

Posted - 2007-01-16 : 10:01:44
Hi
Can anyone tell me how I can CAST these fields AS DECIMAL (19, 2) please?

(SELECT ([Total students] - [withdrawn] - [transferred] - [cancelled]) / [total Students] * 100 AS [Percentage Retained])

Thanks
Daniel

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-16 : 10:11:02
SELECT CAST(([Total students] - [withdrawn] - [transferred] - [cancelled]) / [total Students] * 100 AS DECIMAL(19, 2)) AS [Percentage Retained]

Was not Books Online clear enough for this?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2007-01-16 : 10:21:50
quote:
Originally posted by Peso

SELECT CAST(([Total students] - [withdrawn] - [transferred] - [cancelled]) / [total Students] * 100 AS DECIMAL(19, 2)) AS [Percentage Retained]

Was not Books Online clear enough for this?


Peter Larsson
Helsingborg, Sweden



Thankyou Peter.

I did a google search on CAST but it wasn't very helpful. Books online?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-16 : 10:27:58
Yes, the very comprehensive help file installed with SQL Server and/or Query Analyzer.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2007-01-16 : 10:29:57
quote:
Originally posted by Peso

Yes, the very comprehensive help file installed with SQL Server and/or Query Analyzer.


Peter Larsson
Helsingborg, Sweden



I will bear that in mind.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-16 : 10:33:04
For easy access to the Books Online, just highlight the keyword CAST in Query Analyzer and press SHIFT-F1.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2007-01-16 : 11:08:44
THanks
Go to Top of Page
   

- Advertisement -