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 |
|
NewBird
Starting Member
3 Posts |
Posted - 2010-05-04 : 11:10:30
|
i have a table with 3 columns named ACTUAL,PROJECTNumber and ID i need to retrive one sigle value by writing a query for actuals and formulla is like ACTUAL(Projectnumber)/Actual(Projectnumber) for exampleActual(101)/Actual(102)101 and 102 are different departmentnumbers some how i need to get values with these two departmentnumber filters right in my select clausecan someone help this new bird to start flying? Thanks |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
|
|
NewBird
Starting Member
3 Posts |
Posted - 2010-05-04 : 11:39:08
|
| Its a simple table with 3 columns actual,project and an id actually i want to get just one row of data By dividing actuals of both departments i am confused how to put two where clauses here in one query and then divide numbers1.select actual from tbl where project=1012. select actual from tbl where project=102with these two simple queries i can get both numbers but i want to get these numbers with one query and confused how to place two conditions with in select clause and then divide themrequired result is actual of department 101 / Actual of department 102i hope it make senceThanks |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-04 : 11:58:26
|
I dont understand this perfectly, but maybe this.select actual / (select actual from tbl where dept = '102')from tbl where dept = '101' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-07 : 05:15:17
|
| select 1.0*actual / (select actual from tbl where dept = '102')from tbl where dept = '101'for accuracyMadhivananFailing to plan is Planning to fail |
 |
|
|
NewBird
Starting Member
3 Posts |
Posted - 2010-05-17 : 14:10:35
|
Thanks for your reply..My table OTMH has different account numbers for different KPI's likeAccountNUmber Actual Accounttype 102 15 OTActual 103 17 MHActual104 18 EXPActualnow i am making a view in that view i need to create a ratio column and ratio for KPI is going to be calculated by this formulla (Actual(102)/Actual(103))*100 (15/17)*100i want my select statment to find row of 102 OTActual and divide it by 103 MHActual then multiply it by 100 and produce me a value in new ratio column i have a flope case statement Select (Case when account_number =102 then Actual/(Select Actual where account_number =103)*100 As RatioFrom OTMH; Thanks |
 |
|
|
|
|
|