Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Problem in SQL Query
Wed, Sep 12 2012 11:33 AMPermanent Link

kostas

Hello
I’m still working with the same project and I have a question for an error
The following query works fine

"SELECT sCode as Κωδικός, sName as Περιγραφή,sUnitOM as ΜΜ,sSuplCode AS ΚωδΠρομηθευτή,sWhsalePr as Λιανική,sRetailPr as ΛιανικήΦΠΑ,sComments as Μάρκα,(sInOpenQnt+ sInYearQnt - sOutYrQnt - sAllocQnt) as Διαθέσιμα, case when sComments like '%BMW%' then (sWhsalePr - sWhsalePr * 20/100) else (sWhsalePr - sWhsalePr * 50/100) END From smast where sCode like '1%' or sSuplCode like '%' order by scode"

When I’m giving the column a name with the AS clause before the END

"SELECT sCode as Κωδικός, sName as Περιγραφή,sUnitOM as ΜΜ,sSuplCode AS ΚωδΠρομηθευτή,sWhsalePr as Λιανική,sRetailPr as ΛιανικήΦΠΑ,sComments as Μάρκα,(sInOpenQnt+ sInYearQnt - sOutYrQnt - sAllocQnt) as Διαθέσιμα, case when sComments like '%BMW%' then (sWhsalePr - sWhsalePr * 20/100) else (sWhsalePr - sWhsalePr * 50/100) as Κόστος END From smast where sCode like '1%' or sSuplCode like '%' order by scode"

then I get the error

System.Data.Odbc.OdbcException: ERROR [42000] [Elevate Software][ElevateDB] ElevateDB Error #700 An error was found in the statement at line 1 and column 322 (Expected END but instead found as)

Can you help me?
Wed, Sep 12 2012 3:35 PMPermanent Link

Raul

Team Elevate Team Elevate

Kostas,

IThis looks like ElevateDB and not DBISAM (you're posting in DBISAM
newsgroup).

The error pinpoints the exact problem - you are not ending your case
when end properly.

You need to use

CASE WHEN ... THEN ... ELSE ... END AS <new name>

instead you're using

CASE WHEN ... THEN ... ELSE ...AS <new name> END

Raul


On 9/12/2012 11:33 AM, kostas wrote:
> Hello
> I’m still working with the same project and I have a question for an error
> The following query works fine
>
> "SELECT sCode as &#922;&#969;&#948;&#953;&#954;&#972;&#962;, sName as &#928;&#949;&#961;&#953;&#947;&#961;&#945;&#966;&#942;,sUnitOM as &#924;&#924;,sSuplCode AS &#922;&#969;&#948;&#928;&#961;&#959;&#956;&#951;&#952;&#949;&#965;&#964;&#942;,sWhsalePr as &#923;&#953;&#945;&#957;&#953;&#954;&#942;,sRetailPr as &#923;&#953;&#945;&#957;&#953;&#954;&#942;&#934;&#928;&#913;,sComments as &#924;&#940;&#961;&#954;&#945;,(sInOpenQnt+ sInYearQnt - sOutYrQnt - sAllocQnt) as &#916;&#953;&#945;&#952;&#941;&#963;&#953;&#956;&#945;, case when sComments like '%BMW%' then (sWhsalePr - sWhsalePr * 20/100) else (sWhsalePr - sWhsalePr * 50/100) END From smast where sCode like '1%' or sSuplCode like '%' order by scode"
>
> When I’m giving the column a name with the AS clause before the END
>
> "SELECT sCode as &#922;&#969;&#948;&#953;&#954;&#972;&#962;, sName as &#928;&#949;&#961;&#953;&#947;&#961;&#945;&#966;&#942;,sUnitOM as &#924;&#924;,sSuplCode AS &#922;&#969;&#948;&#928;&#961;&#959;&#956;&#951;&#952;&#949;&#965;&#964;&#942;,sWhsalePr as &#923;&#953;&#945;&#957;&#953;&#954;&#942;,sRetailPr as &#923;&#953;&#945;&#957;&#953;&#954;&#942;&#934;&#928;&#913;,sComments as &#924;&#940;&#961;&#954;&#945;,(sInOpenQnt+ sInYearQnt - sOutYrQnt - sAllocQnt) as &#916;&#953;&#945;&#952;&#941;&#963;&#953;&#956;&#945;, case when sComments like '%BMW%' then (sWhsalePr - sWhsalePr * 20/100) else (sWhsalePr - sWhsalePr * 50/100) as &#922;&#972;&#963;&#964;&#959;&#962; END From smast where sCode like '1%' or sSuplCode like '%' order by scode"
>
> then I get the error
>
> System.Data.Odbc.OdbcException: ERROR [42000] [Elevate Software][ElevateDB] ElevateDB Error #700 An error was found in the statement at line 1 and column 322 (Expected END but instead found as)
>
> Can you help me?
>
Image