3 ms·
It's not that much more complex: if you do SELECT event FROM events WHERE startDate < "2021" then all but one of the results (the one with the greatest `s
by dghf 6y ago
It's not that much more complex: if you do
SELECT event FROM events WHERE startDate < "2021"
then all but one of the results (the one with the greatest `startDate`) will also have an implicit end-date prior to 2021.
- peteradio 6y agoUntil business tells you that endDate is not necessarily greater than startDate. <- real world experience
- NegativeLatency 6y agoSounds interesting can you explain more about it?
- mobjack 6y agoDoing all the logic in SQL requires more complexity using subqueries. It gets uglier if you need to find the contract valid on a certain date based off of a join. These issues can be covered up with code as it will a easier to have reusable functions, but it makes the job of a data analysts much more difficult and error prone.
- dghf 6y agoUglier than having to find the record after the one you're inserting (so you can determine your new record's end date from the subsequent record's start date) and the record before (so you can modify its end date to match your new record's start date)?
- jdmichal 6y agoThis is fine for an open-ended query like the one given, because you still receive all the relevant data. But if you're looking at a range, for the same reason you have one extra at the end, you also have one missing at the beginning. And you can't just filter away missing data.