I'm very sorry Jeremy. That silly typo of mine was the only issued. I shouldn't have polluted this group with that. It was the difference in result. Best, Thiebo
Le mardi 7 juin 2022 à 16:48:39 UTC+2, Jeremy Evans a écrit : > On Mon, Jun 6, 2022 at 10:06 PM Thiebo <[email protected]> wrote: > >> Hello, >> >> I'm trying to do this SQL request (postgresql) : >> >> select SUM (montant) AS solde FROM entrees WHERE account_id = 1 and >> date_de_valeur >= '2022-02-01' and date_de_valeur < '2022-03-01' >> >> Reading the documentation on virtual rows, I do this in Sequel: >> >> DB[:entrees].select{[sum(montant).as(solde)]}.where{(date_de_valeur >= >> '2022-02-01') & (date_de_valeur <= '2022-03-01')}.where(account_id: >> 1).map(:solde) >> > > This generates the following SQL: > > SELECT sum(montant) AS solde FROM entrees WHERE ((date_de_valeur >= > '2022-02-01') AND (date_de_valeur <= '2022-03-01') AND (account_id = 1)) > > The only difference I can see is you are using <= instead of < for > '2022-03-01'. Maybe that is what is affecting your results? > > That last query return an erroneous result. What am I doing wrong? >> > > Hard to tell for sure. I would guess the difference in operator causes > it, but you don't mention how the result is erroneous (what you expect vs > what you received), or provide a self contained example (e.g. create > tables, populate data, then run query) to enable debugging the issue. > > Thanks, > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/7c40a8b5-1e57-4297-afed-750f7ebe6526n%40googlegroups.com.
