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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-05-26 : 08:35:42
|
| gspandian writes "hiI an in the situation to create a computed column which is in nested one it is possible to create a nested computed column in sel server i have tried but it shows errorcreate table dums(salary numeric,a as case when salary * 100/100>9999 then salary*80/100 when salary * 100/100<=9999 then salary*75/100 end,b as case when (when salary * 100/100>9999 then salary*80/100 when salary * 100/100<=9999 then salary*75/100 end) >45 then salary *45/100 end)when (when salary * 100/100>9999 then salary*80/100 when salary * 100/100<=9999 then salary*75/100 end) <=45 then salary*45/100 end)What is the solution?With regardsPandi G.S." |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-05-26 : 09:23:23
|
U want to create a table or u want to select some records ?Is this SQL or T-SQL or some other ? Srinika |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-05-26 : 09:23:54
|
| b as case when (when salary * 100/100>9999 then salary*80/100 when salary * 100/100<=9999 then salary*75/100 end) >45 then salary *45/100 end)is invalid - not sure what you want herewhen has to be precedded by a case.case when x=y then case when a=b then x when c=d then z else y end else t end==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
PSamsig
Constraint Violating Yak Guru
384 Posts |
Posted - 2006-05-28 : 07:36:45
|
This dont give errors and may be what you want, althoug the calculation for b doesnt make much sence (always returns salery * 45 / 100), but I included it anyway.create table dums(salary numeric,a as case when salary * 100 / 100 > 9999 then salary * 80 / 100 else salary * 75 / 100 end,b as case when (case when salary * 100 / 100 > 9999 then salary * 80 / 100 else salary * 75 / 100 end) > 45 then salary * 45 / 100 else salary * 45 / 100 end) -- This one's tricky. You have to use calculus and imaginary numbers for this. You know, eleventeen, thirty-twelve and all those. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-05-29 : 10:12:59
|
| Be sure that you are not storing percentages and ranges and other data in your calculated column! Store your data in *tables* and use joins. You can create your table as is without the computed column and compute your results in a View.See:http://weblogs.sqlteam.com/jeffs/archive/2006/02/10/9002.aspx |
 |
|
|
|
|
|