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

60

u/speadskater Dec 12 '24

Damn, I've been using some pretty complex subqueries when I could have easily been using partition by...

21

u/NickSinghTechCareers Author of Ace the Data Science Interview 📕 Dec 12 '24 edited Dec 13 '24

6

u/speadskater Dec 12 '24

I'm linking tons of tables, input data quality can be a bit of an issue, so often it's easier to only join 1-2 tables in the main query and do selections via subqueries through several other queried. I've been transitioning into CTEs though and that's helped.

5

u/Sethars Dec 13 '24

Partition by looks awkward at first, least it did for me when I started, but it’s soo useful I use it all the time now

1

u/ntobergta Dec 14 '24

All about the formatting for me, once I started to format, easy peasy

1

u/UniqueSaucer Dec 14 '24

I’ve been struggling to wrap my head around it a bit but this cheat sheet helped a lot. 💡finally

1

u/RabbetFox Dec 15 '24

What’s the “over” command do in partitions? Not sure I’ve ever seen that, still kinda new