Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi BDE - SQL - Select - Rundungsproblem (https://www.delphipraxis.net/160783-bde-sql-select-rundungsproblem.html)

stahli 31. Mai 2011 16:50

Datenbank: Paradox • Version: D7 • Zugriff über: BDE

BDE - SQL - Select - Rundungsproblem
 
In einem ALTEN Projekt will ich eine SQL-Abfrage anpassen:

Code:
QueryAw1.SQL.Add('where ... ((p.Gesamtpreis/p.Menge)<>p.Einzelpreis))');
Hier ergeben sich u.U. offenbar 1000tel Rundungsdifferenzen. Die angezeigten Werte im DBGrid sind identisch.
"Round" und "Abs" unterstützt die BDE offenbar nicht.

Kennt einer von den älteren Herren ;-) noch eine einfache Lösung?

omata 31. Mai 2011 17:04

AW: BDE - SQL - Select - Rundungsproblem
 
Vielleicht so...
SQL-Code:
SELECT *
FROM ...
WHERE CAST(Gesamtpreis / Menge * 100 AS INTEGER) / 100.0 <> Einzelpreis

jobo 31. Mai 2011 18:32

AW: BDE - SQL - Select - Rundungsproblem
 
Wenn der Vorschlag von Omata nicht funktioniert, kannst Du noch cast versuchen oder mit istwert < sollwert + delta arbeiten.

BDE SQL heißt local sql und hier gibts Infos dazu:
(sorry, hab die Links vergessen)
http://www.thedbcommunity.com/index.php
http://www.thedbcommunity.com/index....=106&Itemid=46

Auf alten Delphi Installationen fiindest Du vielleicht auch was zum Thema Funktionen (LocalSQL.HLP)

Hier eine Schnippsel aus DER Paradox community:
Zitat:

Functions: Simple Functions

Simple Functions (scalar functions) are generally included in most SQL dialects as an extension to the SQL Standard. They operate on column values in a single row and produce a single value which is included in the result set. Local SQL has several such functions, including:

CAST Convert values from one data type to another. For example, convert a number to a character.
EXTRACT Extract the year, month, or day from a date as an integer.
SUBSTRING Extract a portion of a character column.
UPPER Convert a character column value to all uppercase letters.
LOWER Convert a character column value to all lowercase letters.
TRIM Removes any leading spaces, trailing spaces, or both from a character column value.

Note that these functions are not available with QBE.

Suppose we need to generate a list of all company names, but instead of mixed caps, we need them in all upper case. We can generate a result set containing a capitalized list of all company names using the following query:

SELECT Upper(Company) Company
FROM Customer

Our ANSWER table will have a single column containing the Company name for each company, all in uppercase characters. In the above example, we explicitly named the new column ‘COMPANY’.

These functions are described in detail in the LocalSQL.HLP file. They will be explored in detail in a later article.


Summary

The SQL SELECT statement creates a result set (i.e., an ANSWER table) consisting of specific rows and columns of a table. The result set can consist of simple columns derived from the queried table, calculated expressions or the result of a SQL function. There are two types of SQL functions, aggregate functions, which operate across multiple rows, and simple functions, which operate on single rows. Result set columns may have different names assigned to them during the SQL query using the AS operator in the query.

FredlFesl 1. Jun 2011 06:24

AW: BDE - SQL - Select - Rundungsproblem
 
SQL-Code:
select * from p
where (p.Gesamtpreis/p.Menge) between p.Einzelpreis-0.005 and p.Einzelpreis+0.005;

select * from p
where ((p.Gesamtpreis/p.Menge) > p.Einzelpreis-0.005)
and  ((p.Gesamtpreis/p.Menge) < p.Einzelpreis+0.005);

stahli 1. Jun 2011 10:06

AW: BDE - SQL - Select - Rundungsproblem
 
Ok vielen Dank!

Der Hinweis auf LocalSQL.hlp ist sehr nützlich (D7 kennt das selbst scheinbar nicht) und mein Problem war mit BETWEEN lösbar.


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:54 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz