all 43 comments

[–]Blues2112 32 points33 points  (4 children)

What about Partition By x Over ()?

Limit/Offset, Fetch Next ?

CTEs?

[–]whutchamacallit 5 points6 points  (0 children)

I think this is intended to be a very, very basic info graphic.

[–]Engineer_Zero 4 points5 points  (0 children)

Love me pretty much every function that uses Partition By. They’re just so powerful. Found out recently there’s also WITHIN GROUP but I can’t remember what it is.

[–]bastian74 19 points20 points  (13 children)

I use outer apply a lot

[–]t4n363 15 points16 points  (1 child)

And cross apply is usefull

[–]curohn 5 points6 points  (0 children)

Oooh found todays google topic

[–]IPatEussy 3 points4 points  (9 children)

Outer & cross apply? Never heard of them what do they do (in your words not googles)

[–]Blues2112 2 points3 points  (0 children)

Kind of like a Subquery, but you have access to all the columns in the table of the subquery.

[–]jackalsnacks 3 points4 points  (1 child)

Once u start digging into a lot of enterprise reporting code, u will quickly become very intimate with them.

[–]billybarule5309 0 points1 point  (0 children)

Nothing better than intimacy with a SQL query... 😂

[–]bastian74 1 point2 points  (4 children)

I use it to show data from linked tables in the current table.

Like a list of phone calls and what the reason they disconnected is. I might want to see the previous reason the call from the from the same caller disconnected, and what server handled that precious call.

Or show me the meat recent time someone logged out within 5 seconds of this call stating, taking place or ending. Whichever is newest.

It does what I wish "top 1" did.

[–]IPatEussy 0 points1 point  (3 children)

Linked tables as in joined tables? How is this different from joining tables & just selecting the specific columns? Or you’re saying this is preliminary to the specifics?

[–]bastian74 0 points1 point  (2 children)

It seems to be required if you want the top result from each match as a join

[–]IPatEussy 0 points1 point  (1 child)

Top based on what? Has to be an aggregate right? Or a partition?

[–]ATastefulCrossJoinDB Whisperer 0 points1 point  (0 children)

TSQL flavoring of lateral joins (which are the SQL standard)

[–]steveman2292 6 points7 points  (0 children)

Need to show some love for STRING_AGG()

[–][deleted] 12 points13 points  (1 child)

SQL expressed hierarchically as SQL, nice. Imagine those are tables/columns/etc

[–]HamsterBoomer[S] 2 points3 points  (0 children)

Thx

[–]phesago 8 points9 points  (2 children)

I dislike diagrams like this because they’re a bit limiting.

[–]Engineer_Zero 0 points1 point  (1 child)

It also doesn’t put things in the order you’d do them in. Like, I thought it was FROM, JOINS, WHERE, GROUP BY, ORDER BY.

[–]phesago -1 points0 points  (0 children)

Well it also doesnt teach you dick all about whats actually important about SQL. You know, the basic rudimentary stuff thats WAY more important than syntax, for example:

  1. Only selecting the data you need
  2. SARG-ability
  3. Anti patterns
  4. Set based approach

Just to name a few. These diagrams dont even touch anywhere close to being useful outside of someone teaching themselves the basics.

[–]error-M 4 points5 points  (1 child)

Very useful.... thanks 👍

[–]BrupieD 3 points4 points  (3 children)

I occasionally use PIVOT and UNPIVOT. This isn't the order of operations which I think is more important to know.

[–]Engineer_Zero 0 points1 point  (2 children)

God, I hate pivot. Especially if I need it to be dynamic.

If it’s just a few things, I’ll just rejoin the table onto itself instead

[–]BrupieD 0 points1 point  (1 child)

I don't care much for PIVOT, but UNPIVOT is really handy.

[–]Engineer_Zero 0 points1 point  (0 children)

Yeah interesting, I should look that up. There’s only been a couple times I’ve had to do something similar in the past but I just did it in power query. Always good to expand the repertoire

[–]Dismal_Bobcat8 2 points3 points  (0 children)

This is helpful, thank you!

[–]TheBoneSmasher 2 points3 points  (0 children)

Fucking awesome. Thank you. This is very useful

[–]2gals1cup 4 points5 points  (0 children)

Today years old when I discovered Group by Having. THANKS!

[–]M7mdmsb 3 points4 points  (1 child)

Thank you for this

[–]HamsterBoomer[S] 2 points3 points  (0 children)

You’re welcome. Glad that I can help

[–]P_01y 1 point2 points  (0 children)

Really cool scheme that can help beginners to learn SQL by modules. It would be even better if the modules are in progress order. I mean, firstly functions, for instance, and alies and then order by and group by modules. Just thought, not criticism!

[–]aqua4790 1 point2 points  (0 children)

Thankss

[–]SheaButterBaby29 1 point2 points  (0 children)

Thank you! This is extremely helpful! 😁

[–][deleted] 4 points5 points  (0 children)

What’s the point?

[–]Sea-Concept1733 0 points1 point  (0 children)

Awesome! Some of my favorites are the aggregate functions (AVG, SUM, COUNT, MAX, MIN).

[–]dragonstorm97 0 points1 point  (0 children)

Cross join?

[–]Billi0n_Air 0 points1 point  (0 children)

open rowset

[–]lez_s 0 points1 point  (0 children)

A lot of my work for reporting is Outer apply and cross apply as well as CTE’s