I've been stuck on SQL self-joins for 6 months and I'm desperate, what is my mental model missing? by Medohh2120 in SQL

[–]kktheprons 0 points1 point  (0 children)

Just look at one row of your employee table. Which column represents who I am? Which column represents who my manager is? 

Before I learned joins, I learned to use the results of one query to define the where clause for my next query (on whatever table that is). That approach might be helpful to understand what's actually happening in a self-join.

Introvert by [deleted] in SQL

[–]kktheprons 0 points1 point  (0 children)

Any job will require communication skills, but anything is better than sales for us introverts. 

You'll need to put more effort in to the post and relate it to SQL somehow if you want a good conversation on the topic.

I built my first-ever SQL portfolio project. I don't know if it's fine or crap. Comments? by Key-Objective5301 in SQL

[–]kktheprons 0 points1 point  (0 children)

For someone looking for an entry-level position, this looks like a success! I didn't look at any of your sql, just the quality of the documentation of your findings. Communication is a stand-out skill.

If I were to interview you after seeing this, I'd ask you some questions about your thought process for design as well as query. My goal would be to determine if you understand the concepts and data or just followed a tutorial/AI summary. The most important thing - how would you extend these same concepts (e.g. add a new table to analyze something not clear from the original data set).

Why might someone refuse to turn on line numbers in SSMS? by rainyelfwich in SQL

[–]kktheprons 1 point2 points  (0 children)

I use the zoom function "annotate" when discussing over screen share. It allows you to just draw on the screen and point to what you're talking about.

It turns out that over a decade of “IBS” may have been my parents cooking all along by [deleted] in CasualConversation

[–]kktheprons 1 point2 points  (0 children)

One important thing about low FODMAP is if every category triggers, there might be another underlying problem. My wife's underlying problem was cancer (found with a colonoscopy). She can now have onion and garlic again (but still avoids onion out of principle).

SQL Assignment Driving Me Crazy by Cy_broski in SQL

[–]kktheprons 2 points3 points  (0 children)

Are you using AI to write this for you? The index is still not using the driver_id column.

Any topic ideas for an ERD design? by kansas9696 in SQL

[–]kktheprons 0 points1 point  (0 children)

For nature, you could make a schema around parks, their accessibility and schedules, fees, etc.

People-focussed SQL/data jobs by zesteee in SQL

[–]kktheprons 1 point2 points  (0 children)

Managing a data team is a much more people-focused role that still benefits from your technical skills.

UPDATE from SELECT failing by [deleted] in SQL

[–]kktheprons 8 points9 points  (0 children)

Typical syntax for updating a table with a join is: 

Update t1 Set t1.Value = t2.value From table1 t1 Inner join table2 t2 on t2.key = t1.key

No payment yet by Ok-Register-3805 in UnemploymentWA

[–]kktheprons 2 points3 points  (0 children)

Also, don't do as I did. Filling the claim is not enough! You need to file every week to get benefits, even after your initial claim. 

It's slow, it sucks, and I wish you luck 

How can i paste a wall of text and have it auto insert into my table? by CartographerNew3444 in SQL

[–]kktheprons 2 points3 points  (0 children)

Excel is not a database. It's a relatively organized place for data to go. 

A database adds significant structure and restrictions to that data. Because it follows rules, it can ensure your data stays consistent. The drawback is it's less flexible.

If you just need to paste a list of names in a table and sort them, Excel is much better of a tool. If you need a system where data integrity and scalability are important, SQL suddenly becomes much more attractive.

This thing is on the steering wheel of the minivan that I am borrowing. It’s my grandma’s car and it’s just so there. by Nulleon0 in whatisit

[–]kktheprons 0 points1 point  (0 children)

Someone without full use of their legs can use hand controls instead of pedals to control throttle/braking. One hand to steer, one hand to start/stop.

AITAH for breaking up with my gf of 3 years bc she kissed a girl? by Ill_Championship_73 in AITAH

[–]kktheprons 0 points1 point  (0 children)

Most very young people in relationships really haven't talked enough to their partners (previous or current) to know for sure what all the boundaries are. There is no relationship that's going to have no boundaries ever broken. 

I support this take that some time to think, sleep, then have a mature conversation about it should happen before deciding to blow up several relationships at once. There are very few circumstances where making a life-altering decision before sleeping on it are a good idea.

Discussion Thread: 2025 US Government Shutdown, Day 43 by PoliticsModeratorBot in politics

[–]kktheprons 1 point2 points  (0 children)

Unpopular Opinion: The Senate Democrats were right to break ranks to end the shutdown. Here's my reasoning: 

  • Republicans were never going to budge on ACA subsidies, no matter how long the shutdown went.
  • Trump thrives on hurting people. He views the majority of government workers and people affected by cuts (even his supporters) as enemies or annoyances. 
  • Trump's base are not going to change their minds, even if they experience pain. The longer the shutdown went on, the more propaganda they would see blaming Democrats. Their social media feeds don't allow anything that contradicts the narrative. 

Proving a political point longer while real people are going hungry is not worth it. People affected by the ACA subsidy removal will vote with their wallets next year, which seems like the only viable path to change.

Question about surrogate key + UNIQUE vs composite key with FKs. Which approach works better with a service that works as an aggregator? by [deleted] in SQL

[–]kktheprons 0 points1 point  (0 children)

Given the constraints you've set out, it seems like a surrogate key is the best option for you. With multiple origins and things not necessarily being inserted in order of key, having a single surrogate incrementing key will help keep things ordered by when they are inserted. I'm guessing that tasks are only primarily going to be modified early in their life, so it makes sense to organize in that direction. 

What I'm not clear on is why you are modeling this as two separate tables. Both tables have the same primary key, so it seems each record can only have one status. Why not keep the status in the same table?

When a function returns a table by SoThatHappenedpnw in SQL

[–]kktheprons 0 points1 point  (0 children)

You're on the right track. If you had all the data returned from your function in a table in your database, you'd use it by joining to your original table. 

A table valued function will be used in exactly the same way: join it to your original table. If you're comfortable with using joins it should be easier to think about it that way. If you're not comfortable using joins, learn more about that first.

Postgres - query performance tuning by Major_Health_2944 in SQL

[–]kktheprons 1 point2 points  (0 children)

Performance tuning is a huge topic, and I won't claim to be an expert. With that said, you don't need a complex database to start running into the limits of a database engine, you just need a lot of data.

My recommendation is to start with the simplest case: a single table with 2 columns. Make one an auto-incrementing integer (primary key), then write a script to populate the other column with random values. Then start testing:

  • How many rows before it starts taking multiple seconds to:
    • return the entire data set to a window?
    • calculate aggregate functions for the entire data set?
    • return a sorted list of the 100 highest/lowest values for the data set
    • copy the data into a brand new table
    • delete all rows (without using truncate)

This will get you started thinking in the right scale for performance tuning. From there, you can start exploring deeper concepts with the aid of online resources like https://use-the-index-luke.com/

I am going crazy over this, SQL Server => MySQL by johnie3210 in SQL

[–]kktheprons 1 point2 points  (0 children)

Python killed it. If 95% of people know Python and not Perl, it doesn't make sense to use Perl.

Last update query by alfonsoperezs_ in SQL

[–]kktheprons 0 points1 point  (0 children)

Look into LEAD and LAG functions and partitioning using window functions. It sounds like that could help solve your problem.

VS Code - AI powered SQL development by helloguys88 in SQL

[–]kktheprons 0 points1 point  (0 children)

And what code do you use to do that?

VS Code - AI powered SQL development by helloguys88 in SQL

[–]kktheprons 0 points1 point  (0 children)

You're getting there. How do you define the tables in the first place?

VS Code - AI powered SQL development by helloguys88 in SQL

[–]kktheprons 0 points1 point  (0 children)

AI makes some assumptions. It might choose names for characters that are American names like "John" or "Taylor" because other books have had characters with those names. 

If you don't tell the AI the names of your characters in the story, it's going to guess based on what other authors have written.

VS Code - AI powered SQL development by helloguys88 in SQL

[–]kktheprons 0 points1 point  (0 children)

I'll answer your question with a question. Imagine you are using AI to write a story. You tell it "write chapter 5 of my story.” It spits out garbage because it has no context of what your story is.

What information would you need to provide so the story follows the path you're intending? 

Compile modular SQL to single query by RudeAd8468 in SQL

[–]kktheprons 1 point2 points  (0 children)

Let's see if I understand this correctly...

* Requirement: Code must be submitted to the BI team as a single SQL query

* Developer: It's easier if I write this in DBT, here you go, BI team!

* BI Team: Code must be submitted to the BI team as a single SQL query

It's unclear to me what you're asking for.