FROM tbtrades y
FROM tbtrades x
Why is the same table aliased twice? Don't you want a UNION between two tables?No, the y is in a subselect (presented as a field in the main select).Code: [Select]FROM tbtrades y
Why is the same table aliased twice? Don't you want a UNION between two tables?
FROM tbtrades x
Untested:That's what Fiddle is for :D
Here is a working SQL statement.You didn't simplify it.... you just broke it ;D
If I simplify it, - it becomes wrong.
Yeah, with a small difference: I've introduced a Partition now in the SUM OVERUntested:That's what Fiddle is for :D
https://dbfiddle.uk/MsMsTHW_
But this is the exact same SQL from the other topic, so I don't know why this new topic was opened.
And even this could be done with a Min/Max-Call per zuKonto
If he selects "all" I can select a "far away" border for the date, which is ugly and a source for future errors.
Therefore I removed the where-clause, if the user clicks "show me all you have".
2)Understandible.
Why I spoiled the rvk-code by taking out the "where":
-
The code is behind an interface. The user can select in a form, if he wants to see "all" or only a period.
If he selects "all" I can select a "far away" border for the date, which is ugly and a source for future errors.
Therefore I removed the where-clause, if the user clicks "show me all you have".
NEVER EVER use localized date-representations in Queries
EDIT: Just saw it: NEVER EVER use localized date-representations in Queries!!Uh, the DD.MM.YYYY notation is one of the standard ones.
Your WHERE-Clause uses German notation. That's a BIG hidey-hole for bugs.
Note that Firebird does not honor the Windows or Linux date locale format when interpreting date literals. Its interpretation of all-number date formats is decided by the separator character. When dot (.) is used as separator, Firebird interprets it as the non-U.S. notation DD.MM, whereas with any other separator it assumes the U.S. MM/DD notation. Outside the U.S. date locale, your applications should enforce or convert locale-specific DD/MM/CCYY date input to a literal that replaces the forward slash with a period (dot) as the separator. 'DD.MM.CCYY' is valid. Other date literal formats may be substituted.
But I also prefer the YYYY-MM-DD notation
You can use FormatDateTime('yyyy-mm-dd', now) to convert a date to a string.QuoteBut I also prefer the YYYY-MM-DD notation
How would you generate a string as best stlye for SQL use if there is given a date?
In other works.
myDateTimePicker.Date => myDateString
usage idea
select * from myTable where mydate = MyDateString
(who did not follow the thread: ParamByName is not possible)
It also should be always UTC.Have to disagree with the „always“.
It was an intentional decision of people with a way higher paygrade than me.+1
Nicole comes from Austria as well.I'm not sure if you know... but you can just do .ParamByName('DATEPARAM').asDateTime.
Why I think it not possible to do by ParamByName:
The date-string of the SQL is generated by a different unit.