Board index » delphi » SQL Count
2003-11-06 12:34:05 AM
I have 2 tables: Transactions and Payments. Transactions has a DateTime
Stamp and TransactionNumber fields and Payments has TransactionDate and
I am trying to get a transaction count from a given time and date range, but
I am not getting the correct results. I tried using Distinct to get the
correct result, which helped, but did not work either.
My code looks something like this:
SQL.Add('Select Count(Distinct P.TransactionNumber) As TransCount
From Payments P, Transactions T');
SQL.Add('Where (P.TransactionDate = Cast(T.Date_Time As Date)) And
(P.TransactionDate < "05/13/2003")');
I will be adding the time constraints to this after I get this part to work.
How can I get the correct Count of Transactions for a given date/time range?
I have tried dozens of ways, but none work when I go to multiple days.
Thanks for any help.