Reputation: 15754
I know that in SQLite, we use the LENGTH
function instead of len
. But when I want to use the LENGTH
function with a subquery like so:
select length(select name from tblNames where name=1)
I receive an error. Here is the Microsoft SQL version of the expression:
iif(len((select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)))>0,( select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)),Cstr(Dr.Fr)) as Fr,
I converted the above expression into SQLite as so:
(case length((select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=CAST(Dr.Fr as TEXT))>0 ( select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)) else CAST(Dr.Fr as TEXT) end) as Fr,
What I'm I doing wrong about? Can't I just use the SUBSELECT
query with the LRNGTH
function? Any suggestions on how to solve this problem?
Upvotes: 3
Views: 554
Reputation: 1218
You will want to restructure your statement to be more similar to the following.
select length(name) from (select name from tblnames where name=1);
You can manage this a bit more easily by aliasing the subselects if you like.
select length(t.name) from (select name from tblnames where name=1) as t;
Upvotes: 2