Hi. I am converting a lot of queries to views, and i'm sort of in a gridlock on how to write this line in T-Sql:
In english:
I want the field "kapitalned" to be 0 if the field "date" is null, or greater than the field "kursdato". If its not I want to return a sum of the field kapitalnedsettelse.
I suppose I should use a case statement, but im in a gridlock on how it should be written. Any suggestions? (i have many of lines like this, so i just need a kick in the right direction).
Any help is deeply appreciated!
Code:
Sum(IIf(IsNull([dato]) Or [dato]>[Kursdato],0,[kapitalnedsettelse])) AS kapitalned
In english:
I want the field "kapitalned" to be 0 if the field "date" is null, or greater than the field "kursdato". If its not I want to return a sum of the field kapitalnedsettelse.
I suppose I should use a case statement, but im in a gridlock on how it should be written. Any suggestions? (i have many of lines like this, so i just need a kick in the right direction).
Any help is deeply appreciated!