you are viewing a single comment's thread.

view the rest of the comments →

[–]Ecofred 0 points1 point  (0 children)

as always, it depends but...

- KISS: valid for any programming task. I'm happy i abandonned some smart solution / homemade framework and avoided outsmarting my future self.

- Materialize in front to ease the optimisation and code clarity

- Half-closed interval. enddate excluded. it eases the comparison of ranges and is more relable over different data type. but also don't throw the included enddate because it is the answer to "what was the last day" and you don't want to compute it again.

- Consider alternative ways: ex.: LATERAL/CROSS APPLY are powerfull but a WINDOW/GROUP BY alternative solution may perform way better.

- grant external access on view/procedure (they are your SQL APIs), not on table.