Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Adding SQL Criteria based on expression

edited August 2005 in General
Is it possible to add a SearchCriteria via SQLBuilder based on a calculated
field that is an expression?

e.g.

I want to filter a report where the value of my stock is greater than a
particular amount.

The sql would look like:

SELECT ProductCode FROM Product
WHERE (CurrentStock * AverageCost) > 100

TIA,

Simon

Comments

  • edited August 2005
    Hi Simon,

    The SQLBuilder object does not support adding calculations directly into the
    where clause, however you could create a calculated field and filter your
    data based on that field. See the TdaSQLBuilder.CalcFields topic in the
    ReportBuilder help file for more information.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2005
    Hi Nico,

    I can create the calcfield in code and that appears in the sql just fine,
    but how do i apply a filter? It works fine the report designer as the
    autosearch criteria is replaced by the expression in the sql when I select
    the calculated field. How can I achieve this in code? When I try to add the
    expression as a searchcritera it seems that because the expression is not
    seen as an available field then it is discarded.

    Best regards,

    Simon
  • edited September 2005
    Hi Simon,

    Try creating the calc field in your SQL code before running your
    application, giving it a proper alias. Then try adding that calculated
    field to your search criteria using the SQLBuilder.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.