Hi,
I would like to create an SQL string to give me records basing on a MAX value. This value is DATE.
The string that I use and is not working is:
SELECT DISTINCT Konta.Symbol, ObrotyKsiegowe.SaldoWn, ObrotyKsiegowe.Data, Konta.Typ FROM ep15_opisie.dbo.Konta Konta, ep15_opisie.dbo.ObrotyKsiegowe ObrotyKsiegowe WHERE ObrotyKsiegowe.Konto = Konta.ID AND (ObrotyKsiegowe.Data<={ts ' 2015-05-31 00:00:00'}) AND ObrotyKsiegowe.Data = (SELECT MAX(ObrotyKsiegowe.Data) FROM ep15_opisie.dbo.Konta Konta, ep15_opisie.dbo.ObrotyKsiegowe ObrotyKsiegowe WHERE ObrotyKsiegowe.Konto = Konta.ID AND (ObrotyKsiegowe.Data<={ts ' 2015-05-31 00:00:00'}))
I cannot upload images but this string selects only records with ObrotyKsiegowe.Data = 2015-05-31. What I want to do, is to have something like that:
a abcde 2015-03-31
b abcde 2015-02-15
c abcde 2015-03-31
and my query gives me:
a abdde 2015-03-31
c abcde 2015-03-31
And it ignores the 'b' record completely. Oh, and one more thing. The database would look like this:
a abcde 2015-01-01
a abcde 2015-01-02
a abcde 2015-01-03 and so on.