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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 i got big problem guys

Author  Topic 

gurukmoon
Starting Member

2 Posts

Posted - 2014-07-01 : 14:35:04
tablename_1
id column
1 term_loan(tablename_2.column2)*log(tablename_2.column3)
2 max(tablename_2.column3)+log(tablename_2.column2)*58
3 log(term_loan(tablename_2.column2))+58* max(tablename_2.column3)

table_2
id column2 column3
1 25000 30000
2 null 15000
3 -15000 null
4 null 45000

this table contains formulas column which contains another table column values.while retrieving data if those columns contains null values i need to replace it with 0.(for this i need to write case statmnt n replace those case statmnt with column names in the formula column.)
but, for log it is a problem as log(0) is undefined so i need to write case statemnt to replace null values with 1 wherever log is there.
ex:
output: id column
1 term_loan(case when(tablename_2.column2) is null 0 else (tablename_2.column2))*log(case when(tablename_2.column2) is null 0 else (tablename_2.column3))

so on

am using this column function in a variable in my stored procedure

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-01 : 15:13:51
I don't understand your post, but I think you can just use the ISNULL or COALESCE functions for the columns that do contain nulls.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

gurukmoon
Starting Member

2 Posts

Posted - 2014-07-02 : 00:13:31
am using this column as a variable in my stored procedure to get the score
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-07-02 : 00:54:38
looks like you need Dynamic SQL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -