on 03-30-2016 11:45 AM
Hi,
Instead of writing custom script you can create variable for the same at report level .
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried by replacing len value of custodain '3' as 3 ? 7 also is there any specific reason using custom sql . why because it is not recommended always .
Take the cln length object in query filter and aplly filter as >3 now see sql code how it was generated for this
and try to define same
If it is ameasure /string first make sure if it is measure then try as above.
Thanks
Hi,
You cannot put condition as the output of then in a case stament.
If your requirement is to filter name fields whose value is null or whose length is either less than 3 or greater 35
then try below
length(name) ❤️ or length(name)>35 or name is null
You cannot compare null with equal to operator this will not give null instead gives the data containing string as null.
there is no need to keep the case statement to check for nulls i.e name<>'' then only get the length of the name field and compare it with some numbers.
because length('') gives null and it will fail for both ❤️ and >35 condition
Hope i have not confused you
Hi Moumita,
As far as my understanding goes, IF THEN ELSE statement will not work in simple SQL.
You will have to use CASE WHEN ELSE as a substitute. Please try and check.
Regards,
Yuvraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yuvraj
The in immediate pic above i have used case only in custom sql ,but its throwing error , and I do have one more doubt : actually there is length() function present not len(),but when i used length() it throws error that internally its not recognized funtion, however the len() function is accepted without errors.Wondering how
Hello Moumita,
What is your requirement exactly may be we can tweak the logic in another way to get this done?
Regards
Niraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Moumita,
If I understood correctly, you want to substitute name1 as null for the following situations:
1. when name1 is blank
2. when name1 is less than 3 characters
3. when name1 is greater than 35 characters
then the following syntax should be part of select in your SQL:
case
when len(dbo.stg_cmdb_clnsd.ln1_name) < 3
then 'NULL'
--then NULL
when len(dbo.stg_cmdb_clnsd.ln1_name) > 35
then 'NULL'
--then NULL
else
dbo.stg_cmdb_clnsd.ln1_name
end
Also, please note, that 'NULL' will actually show the word "NULL" in the output, to get a blank use NULL (without quotes).
Just for your info, the correct syntax of case in where clause is as follows:
where <table>.<column> =
case
when <condition1>
then <calculated output 2>
when <condition2>
then <calculated output 2>
else <calculated output 3>
end
Regards,
Goutam
Hi,
try using length instead of len,
Regards,
Rogerio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.