Subject Re: Query error
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 2 Sep 2023 13:25:35 +0200
Newsgroups dbase.getting-started

On 2023/09/02 09:55, Mervyn Bick wrote:

>>  sql = [Select CAST(TestDate as Char(10)) d.TestDate, d.Provider, d.Client, ;
......
>          CAST(d.TestDate as char(10)) cTest_date


Where more than one table is involved in a SELECT statement each field
listed must be qualified by using the table name or a correlation name
i.e an alias.  The field used in the CAST() function must, therefore, be
qualified.  The calculated field created by CAST() is being added to the
rowset created by the SELECT.  This calculated field is nothing to do
with the fields in the DemoData table so it can't be qualified by using
the table name or correlation name.

I've used a new name for the calculated field but this is a personal
preference.  As you haven't included d.TestDate as as date field as well
you can use TestDate (unqualified) as the calculated field's name.

Including the the date field as well as the character field

   CAST(d.TestDate as char(10)) Test_date, d.TestDate,......

would create the following fields in the query's rowset.

       TestDate,TestDate(1),Provider,Client...



>>        LOWER(d.Category) LIKE :Category AND ;
>>        LOWER(d.Allergen) LIKE:Allergen ;

Here the fields included from the rowset are actual, and not, calculated
fields.  The correlation names are optional.

>>        ORDER BY TestDate, Category, Allergen ]

If TestDate in the ORDER BY clause is the calculated field it must be
unqualified.  For the other two fields qualification is optional.

Mervyn.