SqlZap (@sqlzap) header
SqlZap (@sqlzap) profile picture

Learn SQL with me. Made by @csaba_kissi

Joined November 2023
Replying to @csaba_kissi
My activity..
2
40
Use IS DISTINCT FROM for NULL-safe comparisons: Unlike <>, it treats NULL as a comparable value: NULL vs NULL → not different NULL vs a value → different two different values → different Supported by PostgreSQL and several other SQL databases.
2
2
236
SQL tip 💡 Use a window frame to calculate a running total without collapsing rows:
1
1
3
270
Use FILTER to calculate multiple conditional aggregates cleanly:
1
2
208
You can use NULLIF() to prevent division-by-zero errors. When users is 0, NULLIF(users, 0) returns NULL, so the query returns NULL instead of failing.
43
Replying to @sevalla_hosting
This sample code shows how to restore the MYSQL backup from the zipped file:
1
3
29
Replying to @sevalla_hosting
This is how you can set aliases for columns in SELECT
1
3
76
You can also filter JSON like you can in SQL.
JavaScript - JSON methods
33
Replying to @sevalla_hosting
Here is one incredible sample query on how to search in the MYSQL JSON field. Assuming you have a table called users with a JSON column named profile, and you want to find all users where the age field inside the JSON object is equal to 30:
1
3
37
Replying to @sevalla_hosting
Here is the version with a subquery. I like the version that uses "WITH" more.
2
2
49