| Author |
Topic  |
|
|
andrewcw
Posting Yak Master
USA
129 Posts |
Posted - 01/20/2006 : 13:31:54
|
SELECT Mean_F, StdDev_F, NumGadgets, LastUpDate, Proc_FKey, NumFails, NumFails / NumGadgets AS MeanFailure FROM dbo.StatProcMain WHERE (Proc_FKey = 7)
If I use + or * I get the calculated field, but / and I get 0. where numGadgets = 50 and NumFails = 10
How do I represent division ? Thanks 
andrewcw |
|
|
Srinika
Flowing Fount of Yak Knowledge
Sri Lanka
1378 Posts |
Posted - 01/20/2006 : 13:43:59
|
/ - does integer division if both denominator & numerator r integers thus 3/7 = 0
convert either or both to float or decimal |
 |
|
|
andrewcw
Posting Yak Master
USA
129 Posts |
Posted - 01/20/2006 : 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 specification
andrewcw |
 |
|
|
Srinika
Flowing Fount of Yak Knowledge
Sri Lanka
1378 Posts |
Posted - 01/20/2006 : 13:45:32
|
heh hey 1 second
|
 |
|
|
andrewcw
Posting Yak Master
USA
129 Posts |
Posted - 01/20/2006 : 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 MeanFailure FROM dbo.StatProcMain WHERE (Proc_FKey = 5)
andrewcw |
 |
|
|
Srinika
Flowing Fount of Yak Knowledge
Sri Lanka
1378 Posts |
Posted - 01/20/2006 : 14:19:47
|
Check the convert function in Books OnLine of Query Analyzer
check this
declare @a int Set @a = 3 Print @a/7
and then check Print convert(decimal(4,2), @a)/7
Use the same in ur fields Print 3/7.0
|
 |
|
|
andrewcw
Posting Yak Master
USA
129 Posts |
Posted - 01/20/2006 : 16:29:25
|
Thanks I will have to see how I could use that within an ad hoc query instead of a stored procedure
andrewcw |
 |
|
|
andrewcw
Posting Yak Master
USA
129 Posts |
Posted - 01/20/2006 : 17:08:48
|
SELECT Mean_F, StdDev_F, NumGadgets, LastUpDate, Proc_FKey, NumFails, CONVERT(real, NumFails) / CONVERT(real, NumGadgets) AS MeanFailure FROM dbo.StatProcMain WHERE (Proc_FKey = 5)
IT NOW WORKS FINE THANKS TO SRINIKA !
andrewcw |
 |
|
| |
Topic  |
|