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 |
andrewcw
Posting Yak Master
133 Posts |
Posted - 2006-01-20 : 13:31:54
|
SELECT Mean_F, StdDev_F, NumGadgets, LastUpDate, Proc_FKey, NumFails, NumFails / NumGadgets AS MeanFailureFROM dbo.StatProcMainWHERE (Proc_FKey = 7)If I use + or * I get the calculated field, but / and I get 0.where numGadgets = 50 and NumFails = 10How do I represent division ? Thanksandrewcw |
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-20 : 13:43:59
|
/ - does integer division if both denominator & numerator r integersthus 3/7 = 0convert either or both to float or decimal |
|
|
andrewcw
Posting Yak Master
133 Posts |
Posted - 2006-01-20 : 13:44:00
|
OH I know part of the problem, the calc field wants to be an integer, what do I do to specify a real ( when I reversed it to get 50/10 I got an answer ... So please help with field specificationandrewcw |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-20 : 13:45:32
|
heh hey 1 second |
|
|
andrewcw
Posting Yak Master
133 Posts |
Posted - 2006-01-20 : 13:48:39
|
OK ?? I how do I do that ??? : ( not like this:)SELECT Mean_F, StdDev_F, NumPlanes, LastUpDate, Proc_FKey, NumFails, type real (NumPlanes) / type real ( NumFails) AS MeanFailureFROM dbo.StatProcMainWHERE (Proc_FKey = 5)andrewcw |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-20 : 14:19:47
|
Check the convert function in Books OnLine of Query Analyzercheck thisdeclare @a intSet @a = 3Print @a/7and then check Print convert(decimal(4,2), @a)/7Use the same in ur fieldsPrint 3/7.0 |
|
|
andrewcw
Posting Yak Master
133 Posts |
Posted - 2006-01-20 : 16:29:25
|
Thanks I will have to see how I could use that within an ad hoc query instead of a stored procedureandrewcw |
|
|
andrewcw
Posting Yak Master
133 Posts |
Posted - 2006-01-20 : 17:08:48
|
SELECT Mean_F, StdDev_F, NumGadgets, LastUpDate, Proc_FKey, NumFails, CONVERT(real, NumFails) / CONVERT(real, NumGadgets) AS MeanFailureFROM dbo.StatProcMainWHERE (Proc_FKey = 5)IT NOW WORKS FINE THANKS TO SRINIKA !andrewcw |
|
|
|
|
|
|
|