CTE with exists() and case()
Hey guys, just wrote this one and I thought I'd share.
https://kyse.link/?p=s&i=weqpZStlVZ7TONs1D3UR
1. Create a CTE that checks if there is an ongoing match and returns a boolean value.
2. Find the closest match in a future date.
3. Only return it if there is no ongoing match.
EDIT: Updated version: https://kyse.link/?p=s&i=r8bpSEIqQVS92bvZxqsn
4 Replies
Very nice! Perfect combination of type-safe and readable IMO. There are ways to make some parts more type-safe but then the code becomes much less readable.
Only thing I'd change is the case statement into
Ah, thank you for the tip, it did not occur to this can be written in such way, but effectively it does the same thing. This is more of an SQL tip than Kysely tip, nevertheless I am glad it happened because I learned a lot of new stuff 🙂
Cheers!
Thank you for sharing ❤️
no problem at all