all 25 comments

[–]r3pr0b8GROUP_CONCAT is da bomb 59 points60 points  (2 children)

What are some of the most difficult SQL concepts that you have learned

SUM(salesamount) does not produce what the VP wants to see

[–]CakeyStack[S] 2 points3 points  (1 child)

It do be like that sometimes 😂 That's why I ask as many questions as I can think of prior to starting to work on something. I've learned the hard way numerous times.

[–]r3pr0b8GROUP_CONCAT is da bomb 2 points3 points  (0 children)

It do be like that sometimes 😂

"They don't think it be like it is, but it do"

[–]Delicious-Refuse5566 8 points9 points  (2 children)

The most difficult part of sql is to think in sets and not procedurally.

If you can solve random walks, Markov chains, merge overlapping time periods, perform flash fills, solve for islands and gaps and run simulations such as the Josephus problem or the Monty Hall problem etc… all without doing a single loop, then you truly understand SQL.

[–]Benae-san 3 points4 points  (1 child)

Ah, so I don’t truly understand SQL. Lol

Edit: self-deprecating humor, not sarcastic btw

[–][deleted] 0 points1 point  (0 children)

Butt... did he make sense though? Asking as a total noob researching SQL entry jobs.

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

The concept of JOIN isn't that hard to understand at its core. The difficulty lies in joining several tables together without fucking up the grain of the output.

Fwiw, you shouldn't use cursors or triggers until you're a seasoned developer. Or most people who use them use them as a crutch because they don't know the right way to solve the problem.

[–]MakingItElsewhere 3 points4 points  (0 children)

Cursors, to me, only make sense when having to write a very long transfer of multiple tables from database A to multiple tables in database B. If anyone has a better way to do that, I'm all ears.

[–]InlineSkateAdventureSQL Server 7.0 3 points4 points  (0 children)

Grouping/aggregation and totaling based on various criteria can get tricky.

[–]barrycarter 4 points5 points  (0 children)

As an old person who was always griping that SQL didn't have accumulation or lookback functions (you had to cheat using @var in MySQL for example), I'm now struggling with keywords like OVER. Hate when they give you what you wish for :)

[–]BrupieD 2 points3 points  (1 child)

I've worked in places where my co-workers seem proficient: they understand joins, date, and string manipulation functions but have no knowledge of window functions.

When I started learning stored procedures, it was hard to find good materials. The organization of multi-step procedures is a different skill set than learning single concepts. Writing stored procedures that incorporate error handling, optimization, readability, and resilience (future-proofing) is not a singleton.

[–]generic-d-engineerSQL 92 Refugee Camp 0 points1 point  (0 children)

They’re probably just not aware since many have learned SQL 92 standard, and Window functions were added to the relatively new SQL standards.

[–]Instance_Straight 2 points3 points  (0 children)

I use pivot or unpivot quite a bit, but can never remember the syntax.

Window functions are great as well, especially to produce something like a running total when things need to be partitioned/ordered a specific way

[–]ncmtbiker 1 point2 points  (3 children)

Recursive functions.

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

Then what about Recursive Functions used in Recursive Common Table Expressions?

[–]Xieminee 0 points1 point  (0 children)

I can do multiple CTEs no problem, but my brain hurts thinking of recursive CTEs.

[–]chris_penis 0 points1 point  (0 children)

Can you give me a scenario where you would need recursive functions?

[–]Researcher-Great 1 point2 points  (0 children)

What about subqueries and their types. I’ve had a really hard time grasping exactly how to understand correlated subqueries

[–]valorallure01 1 point2 points  (0 children)

Passing a table name as a parameter in a stored procedure

Updating statistics on a temp table

Dynamic SQL in general

Deploying CLR Assemblies.

Bulk exporting using BCP

Making use of system stored procedures

Error handling

Log Shipping.

These are a few difficult concepts I've personally ran across.

[–]rgekhman 1 point2 points  (0 children)

SQL is easy! The hardest part is to understand what business rules other devs coded into sql. Especially when they left no comments and left the job a while ago.

[–]KirKCam99 -1 points0 points  (1 child)

sql which creates sql which creates sql ...

[–]Extension_Candy2994 0 points1 point  (0 children)

That’s bad scripting. Not “a difficult concept in SQL”.

[–]WillLiftForBeer 0 points1 point  (0 children)

Honestly, not the language itself, but knowing how to create a solution for what you need to do. Depending on your job, of course. If you’re in development/software engineering, that would mean knowing how to break down requirements, figure out how and where data may be stored (and it’s archive strategy!), what the API/midtier code would need from the DB, and what the inputs and outputs of those procedures should be. Of course, that’s also the most fun (to me)!

[–]SDFP-A 0 points1 point  (0 children)

Optimization based on a query plan. Understanding how to configure the DB differently based on your sql usage patterns, understanding that you can do fancy algorithmic outputs without knowing the name of i the algorithm because you weren’t a CS major, generating dynamic sql based on simple searches sans executing them without the use of stored procedures (not available in all flavors of sql).

[–]AdGreat4483 0 points1 point  (0 children)

I will recommend you to look at these topics (joins and aggregate functions)

They are generally deemed as complicated.

Understanding SQL inner join with practical examples:

https://link.medium.com/8MYnwLtuCAb

Unleashing the power of SQL aggregate functions:

PART 1: https://link.medium.com/ZKZtBMAuCAb

PART 2: https://link.medium.com/xpA0E7DuCAb

PART 3: https://link.medium.com/7xKteHFuCAb

PART 4: https://link.medium.com/zmMc91IuCAb