TQuery calculated field and logical operator 
Author Message
 TQuery calculated field and logical operator

I have the following SQL strings in my TQuery component:

Select O.OrderNo, O.CustNo,
       (O.ItemsTotal - O.AmountPaid)  as AmountDue  { This works }
       (O.ItemsTotal > O.AmountPaid)  as Log2       { This does not
work}  
       FROM ORDERS O, CUSTOMER C
       where  O.CUSTNO = C.CUSTNO
       ORDER BY Log2

The calculated field AmountDue works OK, but if I use the logical '>'
operator
it does not work. Does anybody know if  the logical operation also
should work,
or is there any work-around to get it to work.

The idea is to get the Query result sorted according the calculated
True/False
field.

Markku Nevalainen



Sat, 09 Oct 1999 03:00:00 GMT  
 TQuery calculated field and logical operator

Hi Markku

You could try a union:

SELECT O.OrderNo, O.CustNo, (O.ItemsTotal - O.AmountPaid) as AmountDue
        FROM ORDERS O, CUSTOMER C
        WHERE O.CUSTNO = C.CUSTNO AND O.ItemsTotal > O.AmountPaid
UNION SELECT O.OrderNo, O.CustNo, (O.ItemsTotal - O.AmountPaid) as
AmountDue
        FROM ORDERS O, CUSTOMER C
        WHERE O.CUSTNO = C.CUSTNO AND O.ItemsTotal <= O.AmountPaid

If you omit the ORDER clause, the record should be in your desired
order.

HTH

Klaus

On Tue, 22 Apr 1997 10:56:54 -0700, Markku Nevalainen

Quote:

>I have the following SQL strings in my TQuery component:

>Select O.OrderNo, O.CustNo,
>       (O.ItemsTotal - O.AmountPaid)  as AmountDue  { This works }
>       (O.ItemsTotal > O.AmountPaid)  as Log2       { This does not
>work}      
>       FROM ORDERS O, CUSTOMER C
>       where  O.CUSTNO = C.CUSTNO
>       ORDER BY Log2

>The calculated field AmountDue works OK, but if I use the logical '>'
>operator
>it does not work. Does anybody know if  the logical operation also
>should work,
>or is there any work-around to get it to work.

>The idea is to get the Query result sorted according the calculated
>True/False
>field.

>Markku Nevalainen



Mon, 11 Oct 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. calculating logical fields with sql?

2. logical operators in pascal, help!

3. Logical Operator Problem

4. Logical Operator Problem

5. Adding calculated fields to a TQuery at run-time

6. Referencing a calculated field in TQuery SQL

7. TQuery component with calculated fields created in runtime

8. TQUERY-Calculated fields

9. TQuery and Calculated Fields HELP

10. Calculated fields and TQuery SQL property

11. How to re-calculate a calculated field

12. LIKE OPERATOR IN TQUERY COMPONENT

 

 
Powered by phpBB® Forum Software