![]() |
SQL-Statement: String to Int
Hallo Forum,
ich möchte per ADODB eine Access-DB in einem Excelmakro abfragen:
Delphi-Quellcode:
Als Ergebnis bekomme ich zwei konkatenierte Strings, z.B.: 31 + 17 = 3117. Ich möchte aber die Summe der beiden Zahlen. Wie kann ich das in das Statement mitaufnehmen?
Select
Invoice.Kontaktaufkommen + ACQC.Kontaktaufkommen as Summe Kontaktaufkommen FROM ... Danke für eure Aufmerksamkeit. |
Re: SQL-Statement: String to Int
Kennt access CAST()?
|
Re: SQL-Statement: String to Int
Zitat:
Delphi-Quellcode:
Das scheint nicht zu klappen. Auch bei Cast meckert Excell...
"SELECT " _
& "[Zeit], " _ & "CInt(Invoice.Kontaktaufkommen) + CInt(ACQC.Kontaktaufkommen) As Kontaktaufkommen, " _ & "[AHT()] As AHT, " _ & " FROM customer ACQC, Invoice" _ & " WHERE Datum = '" & FCDate & "' " |
Re: SQL-Statement: String to Int
Hallo,
zeig doch mal das sql statement mit dem cast und die "Meckermeldung" wäre auch nett Heiko |
Re: SQL-Statement: String to Int
Es gäbe noch die Alternative, die Berechnung in VBA anstatt im SQL-Statement durchzuführen.
|
Re: SQL-Statement: String to Int
Hi,
ehrlich gesagt ist mir nicht klar wie ich "Cast" benutze... Mein Statement sieht jetzt so aus:
Delphi-Quellcode:
Danach bekomme ich folgende Werte:
"SELECT " _
& " Invoice.Zeit, " _ & " Invoice.Kontaktaufkommen as IK, " _ & " Acquiredcustomer.Kontaktaufkommen as AK, " _ & " (CInt(Invoice.Kontaktaufkommen) + CInt(Acquiredcustomer.Kontaktaufkommen)) as Kontaktaufkommen " _ & " FROM Acquiredcustomer, Invoice" _ & " WHERE " _ & " Invoice.Zeit = Acquiredcustomer.Zeit" _ & " AND " _ & " Invoice.Datum = '" & FCDate & "' " IK: 10 AK: 16 Kontaktaufkommen: 26 Wobei in der Tabelle andere Werte stehen: IK: 10 AK: 26 Das sollte also 36 für "Kontaktaufkommen" sein. Ich habe keine Ahnung warum diese Werte rauskommen...!? Kann mich jemand aufklären? |
Re: SQL-Statement: String to Int
SQL-Code:
select ... cast (<feld> as <Typ>) ...
|
Re: SQL-Statement: String to Int
Mein Fehler. Es muss heißen:
Delphi-Quellcode:
Die zusätzliche Bedingung am Schluss liefert mir das Gewünschte! Danke für eure Aufmerksamkeit!
"SELECT " _
& " Invoice.Zeit, " _ & " Invoice.Kontaktaufkommen as IK, " _ & " Acquiredcustomer.Kontaktaufkommen as AK, " _ & " (CInt(Invoice.Kontaktaufkommen) + CInt(Acquiredcustomer.Kontaktaufkommen)) as Kontaktaufkommen " _ & " FROM Acquiredcustomer, Invoice" _ & " WHERE " _ & " Invoice.Zeit = Acquiredcustomer.Zeit" _ & " AND " _ & " Invoice.Datum = '" & FCDate & "' " _ & " AND " _ & " Acquiredcustomer.Datum = '" & FCDate & "' " |
Re: SQL-Statement: String to Int
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:34 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz