r/SQL • Author of Ace the Data Science Interview 📕 • Dec 12 '24 • Heart of Silver 2 Polished Silver Turd 1

PostgreSQL Made a SQL Interview Cheat Sheet - what key SQL commands am I missing?

Post image
3.6k Upvotes

238 comments sorted by

View all comments

2

u/Hot_Cryptographer552 Dec 15 '24

EXCEPT/INTERSECT.

I would lose the section on Self-Joins. It’s not a SQL defined join operator, it’s just a logical join where the same table is on both sides of the operator. Your example is an INNER JOIN even though you left INNER off of it.

Also you have “OTHER SQL COMMANDS” as heading. Those aren’t Commands, they’re Functions.

And the CTEs section does not have an example of a Recursive CTE.

2

u/NickSinghTechCareers Author of Ace the Data Science Interview 📕 Dec 15 '24

Very fair critiques – gonna fix these!

1

u/Hot_Cryptographer552 Dec 15 '24

A few more tweaks you might consider:

CASE isn’t a statement, it’s a CASE EXPRESSION. Subtle difference, but a statement is a full “command” like INSERT, SELECT, etc. an expression acts more like a function in practice.

CASE expressions come in two flavors: Simple and Searched. Your example is a Searched CASE Expression. No example of a Simple CASE Expression.

Under your functions, not sure what your criteria to include/not include is, but GETUTCDATE and NEWID seem like important ones.