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 |
saurabhjj
Starting Member
13 Posts |
Posted - 2007-08-31 : 08:05:05
|
hi,i am working on a sytem where i need to calculate accounting ratios for a business, the data are to be retrieved from the database and i need to calculate the ratios, i am new to wrting stored procedures, so can any one help me out |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-31 : 09:06:24
|
exCreate procedure calc_ratiosasSelect cols,1.0*somecol/othercol*100 as ratio from tableMadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-31 : 09:12:58
|
wouldn'tSelect cols,100.0 * somecol / othercol * 100 as ratio from tablebe enough?also, beware of division by zero.Select cols,100.0 * somecol / nullif(othercol, 0) as ratio from table E 12°55'05.25"N 56°04'39.16" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-31 : 09:18:45
|
quote: Originally posted by Peso wouldn'tSelect cols,100.0 * somecol / othercol * 100 as ratio from tablebe enough?also, beware of division by zero.Select cols,100.0 * somecol / nullif(othercol, 0) as ratio from table E 12°55'05.25"N 56°04'39.16"
Yes it is When there are no hardcoded values, then I used to use 1.0 which in this case not neededMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|