BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

QBE Calculation

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
srdaniel
Guest





PostPosted: Tue Aug 15, 2006 3:10 am    Post subject: QBE Calculation Reply with quote



Does anyone remember how to use QBE's?

I can create a simple one like so

QUERY

CUSTOMER | CustNo | Company | Addr1 |
| Check | NOT BLANK | Check |

ENDQUERY


But what I was wondering was, is it possible to limit the records based
on a calculation between two fields? I have two currency fields and I
only want the records where the difference between the two currency
fields is greater than a specified percentage.

If not QBE, is it possible with SQL?

srdaniel
Back to top
Bill Todd
Guest





PostPosted: Tue Aug 15, 2006 6:31 am    Post subject: Re: QBE Calculation Reply with quote



srdaniel wrote:

Quote:
Does anyone remember how to use QBE's?

I can create a simple one like so

QUERY

CUSTOMER | CustNo | Company | Addr1 |
| Check | NOT BLANK | Check |

ENDQUERY


But what I was wondering was, is it possible to limit the records
based on a calculation between two fields? I have two currency fields
and I only want the records where the difference between the two
currency fields is greater than a specified percentage.

If not QBE, is it possible with SQL?

srdaniel

It is possible with both QBE and SQL, however, I am on the road and do
not remember the exact syntax for QBE. I have no way to look it up
until I get home. With SQL:

SELECT * FROM ATABLE
WHERE FIELD1 - FIELD2 > 23

--
Bill Todd (TeamB)
Back to top
srdaniel
Guest





PostPosted: Tue Aug 15, 2006 7:33 pm    Post subject: Re: QBE Calculation Reply with quote



Bill Todd wrote:
Quote:

It is possible with both QBE and SQL, however, I am on the road and do
not remember the exact syntax for QBE. I have no way to look it up
until I get home. With SQL:

SELECT * FROM ATABLE
WHERE FIELD1 - FIELD2 > 23



Looks like it has something to do with the CALC operator. My old paradox
book mentions hitting F5 and using CALC, but I don't have the full blown
Paradox editor, just Database Desktop and I'm not sure how to get a CALC
working. Here is the delphi function I'm trying to duplicate:


function PremiumChangedEnough( aPremium, aOldPremium: Double;
aChangePercent: Integer ): Boolean;
var
ActualDifference, CheckDifferenceAmount: Double;
begin
ActualDifference := Abs( aPremium - aOldPremium );
CheckDifferenceAmount := Abs((aChangePercent / 100) * aPremium);

Result := (ActualDifference >= CheckDifferenceAmount);
end;
Back to top
srdaniel
Guest





PostPosted: Tue Aug 15, 2006 11:12 pm    Post subject: Re: QBE Calculation Reply with quote

Bill Todd wrote:
Quote:
It is possible with both QBE and SQL, however, I am on the road and do
not remember the exact syntax for QBE. I have no way to look it up
until I get home. With SQL:

SELECT * FROM ATABLE
WHERE FIELD1 - FIELD2 > 23


I got the percentage difference to work with SQL, but I'd still like to
know how to do it with a QBE.

select OldPrem, NewPrem, (((NewPrem-OldPrem)/OldPrem)*100) as
FieldPercentage
from "%s"
where ((((NewPrem-OldPrem)/OldPrem)*100) >= 15) or
((((NewPrem-OldPrem)/OldPrem)*100) <= -15)
Back to top
Bill Todd
Guest





PostPosted: Wed Aug 16, 2006 7:25 am    Post subject: Re: QBE Calculation Reply with quote

Using QBE you need an example element in each of the columns to be used
in the calculation then use the calc operator for the calculation.

QUERY

ORDERITEM | Quantity | UnitPrice | OrderNumber |
| _Qty | _UP | calc _Qty * _UP as ExtendedPrice |

ENDQUERY

If you are going to do much of this try to find a used copy of Paradox
Queries - A Complete Reference by Dan Ehrmann published by M&T. It
truly is a complete reference.

--
Bill Todd (TeamB)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.