Sam Runyon
asked on
I need to take the value and make it say ">30 Days"
I need to take the value and make it say ">30 Days"
Here is what my statement looks like
CASE WHEN Cast(CHEMVAL.value AS NUMERIC(5, 1)) = 0 THEN Cast(CHTKVOL.value AS NUMERIC(5, 1)) ELSE Cast(CHTKVOL.value AS NUMERIC(5, 1)) / Cast(CHEMVAL.value AS NUMERIC(5, 1)) END as [Days Left at Current Rate]
if the value is 30 or greater just display ">30 Days"
Here is what my statement looks like
CASE WHEN Cast(CHEMVAL.value AS NUMERIC(5, 1)) = 0 THEN Cast(CHTKVOL.value AS NUMERIC(5, 1)) ELSE Cast(CHTKVOL.value AS NUMERIC(5, 1)) / Cast(CHEMVAL.value AS NUMERIC(5, 1)) END as [Days Left at Current Rate]
if the value is 30 or greater just display ">30 Days"
That will fail because you can't convert the string ">30 Days" to a numeric value. You'd need to cast the computation to a string to avoid that issue.
ASKER
Scott could you help with the context of the problem.. I am new.. learning at a slow place. :)
Sam
Sam
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your choices are:
1. either you generate the complete string you want to show in the end in SQL; i.e. currently you probably append the word "days" somewhere in the UI or report, wherever it goes into in the end. So now you'd have to remove that, generate the complete string in SQL, and in the UI show only what came from SQL
or
2. Generate those ">30 days" in your report or UI rather than in SQL.
#2 is probably more straightforward. If you tell what is that end-user UI, we can tell more specifically how to achieve that. For example, in SSRS report it would be easily achieved by an expression like =Iif(DaysLeftatCurrentRate .Value<=30 , DaysLeftatCurrentRate.Valu e, ">30 days")
1. either you generate the complete string you want to show in the end in SQL; i.e. currently you probably append the word "days" somewhere in the UI or report, wherever it goes into in the end. So now you'd have to remove that, generate the complete string in SQL, and in the UI show only what came from SQL
or
2. Generate those ">30 days" in your report or UI rather than in SQL.
#2 is probably more straightforward. If you tell what is that end-user UI, we can tell more specifically how to achieve that. For example, in SSRS report it would be easily achieved by an expression like =Iif(DaysLeftatCurrentRate
Open in new window