0

How do I convert the query below to sqlite?

SELECT DISTINCT 
unite.UniteAd+'('+IIf(IsNull(Left(Semt.Semt,50)),'',Left(Semt.Semt,50))+')' 
AS UniteAd 

I tried to use case...when instead of iif but I keep getting error.

Lukas Eder
  • 196,412
  • 123
  • 648
  • 1,411
Mustafa Güven
  • 15,130
  • 10
  • 59
  • 82

1 Answers1

0

You will need to replace IIF and ISNULL with CASE and to replace LEFT with SUBSTR. Also, you need to use || to concatenate, instead of +.

If you've made those changes and it still doesn't work, please post the resulting SQL that is failing. I'd try it for you, but I can't figure out what you mean by:

IIf(IsNull(Left(Semt.Semt,50)),'',Left(Semt.Semt,50))
Larry Lustig
  • 47,541
  • 13
  • 102
  • 154
  • I think this is right SELECT DISTINCT unite.UniteAd + '('+ CASE WHEN SUBSTR(Semt.Semt,0,50) is null THEN '' ELSE SUBSTR(Semt.Semt,0,50) +')' as UniteAd – Mustafa Güven Sep 14 '11 at 12:46
  • What is the purpose of `SUBSTR(Semt.Semt,0,50)`? Are you trying to evaluate whether Semt.Semt is NULL? – Larry Lustig Sep 14 '11 at 12:55
  • I am trying to get first 50 characters of the column which is called Semt. Here I am using SUBSTR instead of LEFT function. – Mustafa Güven Sep 14 '11 at 13:16