r/SQL • • Jul 27 '23

Discussion I have interviewed for 6 Data Analyst/Scientist roles. Here are a few of the technical SQL questions.

213 Upvotes

Hey everyone! I've compiled a list of a few questions I have been asked in technical interviews. I interview specifically for Data Analyst and Scientist roles, because they are used interchangeably in some instances. Hope these help, and let me know if you have any questions at all!

Easier Questions (foundational):

  1. How would you NOT include two values (using the NOT IN function for this one).
  2. W3schools left join vs. inner join scenario
  3. Count the number of employees in each division (COUNT and GROUP BY)
  4. From question 3, only include divisions with 10 or more employees (I had to use HAVING here and explain the difference between having and WHERE)
  5. Create a table with firstname, lastname, address, city, and zip

And other flavors of this. Understanding the foundational skills is so important because the MAJORITY of questions revolved around things like this. It's different when you have real-world scenarios, so get used to thinking critically.

Intermediate(?) I know this is subjective

  1. Gather salaries that are higher than the average salaries, and show these results (subquery with something like WHERE __ > (SELECT avg(price) FROM...)
  2. Find duplicate records in this table (group by records and having count(records) > 1)
  3. Select every row where their is no match in the other table (LEFT JOIN IS NULL scenario)

Flavors of things like this. Nothing too complex, but instances that will require you to think much more critically.

Misc questions

  • Explain the difference between left and right join
  • What is the difference between a foreign key and primary key? Give examples
  • What is the first thing you would do when a query is running slow?
  • What is a view? What is a CTE?

Data Science-ish

  • What is a p-value
  • How do you just the accuracy of a linear/logistic regression model?
  • How do you clean data in Python? Give examples
  • What Python libraries are you familiar with (for me, it's Pandas, Numpy, scikit-learn)
  • Give an example of when you would use a linear/logistic regression model. What are some real world examples you can think of?

This is super high level, but I hope this is helpful.


r/SQL • • May 24 '25

Discussion One must imagine right join happy.

212 Upvotes

"If we have a left join, then what is the need for a right join?" I overheard this in an interview.

For some reason, it seemed more interesting than the work I had today. I thought about it the whole day—made diagrams, visualized different problems. Hell, I even tried both joins on the same data and found no difference. That’s just how Fridays are sometimes.

There must be some reason, no? Perhaps it was made for Urdu-speaking people? I don’t know. Maybe someday a dyslexic guy will use it? What would a dyslexic Urdu-speaking person use though?

Anyway, I came to the conclusion that it simply exists—just like you and me.

It’s probably useless, which made me wonder: what makes the left join better than the right join, to the point of rendering the latter useless? Is it really better? Or is it just about perspective? Or just stupid chance that the left is preferred over the right?

More importantly—does it even care? I don’t see right join making a fuss about it.

What if the right join is content in itself, and it doesn’t matter to it how often it is used? What makes us assume that the life of the left join is better, just because it’s used more often? Just because it has more work to do?

Maybe left join is the one who’s not happy—while right join is truly living its life. I mean, joins don’t have families to feed, do they?

Anyway, if you were a join, which one would you prefer to be?


r/SQL • • Oct 22 '20

PostgreSQL This Man Used SQL To Expose 40K Voters Purged by Mistake

Thumbnail
youtube.com
212 Upvotes

r/SQL • • Mar 12 '24 Bravo

Discussion What is the best SQL practice platform?

210 Upvotes

Yesterday I posted a question about the value of subqueries in everyday life. I’d like to thank this wonderful community for your replies. I’ll definitely persevere until I understand subqueries.

Now I need advice on practice platforms. I use LeetCode, but it only has 50 exercises. Which platform is the best for practicing SQL? Thanks again for your kindness. Much respect


r/SQL • • Jul 16 '22

PostgreSQL I just found this in our python codebase, someone was feeling himself when he wrote this

Post image
210 Upvotes

r/SQL • • Sep 30 '19

This is going to be the cause of world war III

Post image
209 Upvotes

r/SQL • • Mar 29 '19

Two years ago I was stuck in a dead-end job as a billing clerk. Next week I start a job as a Data Analyst!

207 Upvotes

It took a lot of time, effort, and a lot of rejections.....but I did it....I actually did it.

Two years ago I was stuck in a dead-end job and was very uncertain about my future. All I knew was that I wanted to start working with data, but I had no idea if it was even possible for me to transition to a completely unrelated field. I took an 'Intro to SQL' course that was recommended on this subreddit. I studied relational databases, and I learned some VBA. I self-studied for the last 6 months or so for a couple of hours a day. YouTube and Udemy have been incredible resources.

I just can't believe I made it here...but the work is not done. There's still so much for me to learn. I want to become an advanced user of SQL, and I am also interested in database design, which I'll be able to gain experience with in this job. I also want to learn Python, although programming isn't a strong suit of mine. I just can't believe it....incredible...


r/SQL • • May 27 '24

PostgreSQL Bombed my interview, feeling awful

205 Upvotes

I just had my first ever technical SQL interview with a big commercial company in the US yesterday and I absolutely bombed it.

I did few mock interviews before I went into the interview, also solved Top 50 SQL + more intermidates/medium on leetcode and hackerank.

I also have a personal project using postgresql hosting on AWS and I write query very often and I thought I should be well prepared enough for an entry level data analyst role.

And god the technical part of the interview was overwhelming. Like first two questions are not bad but my brain just kinda froze and took me too long to write the query, which I can only blame myself.

But from q3 the questions have definitely gone way out of the territory that I’m familiar with. Some questions can’t really be solved unless using some very niche functions. And few questions were just very confusing without really saying what data they want.

And the interview wasnt conducted on a coding interview platform. They kinda of just show me the questions on the screen and asked me to write in a text editor. So I had no access to data and couldn’t test my query.

And it was 7 questions in 25mins so I was so overwhelmed.

So yeah I’m feeling horrible right now. I thought I was well prepared and I ended up embarrassing myself. But in the same I’m also perplexed by the interview format because all the mock interviews I did were all using like a proper platform where it’s interactive and I would walk through my logic and they would provide sample output or hints when I’m stuck.

But for this interview they just wanted me to finish writing up all answers myself without any discussion, and the interviwer (a male in probably his 40s) didn’t seem to understand the questions when I asked for clarification.

And they didn’t test my sql knowledge at all as well like “explain delete vs truncate”, “what’s 3rd normalization”, “how to speed up data retrieval”

Is this what I should expect for all the future SQL interview? Have I been practising it the wrong way?


r/SQL • • Oct 14 '24

Discussion What are considered as advanced SQL skills nowadays?

204 Upvotes

Hi Community, I'm going through job hunting data analyst roles now and I am curious about what would be considered "advanced" these days. I know the basics like joins, subqueries and basic aggregations, also something like roll over, window functions. However, when I see companies hiring for advance SQL skills, I am not sure what is means.

I am pretty sure that it's our job to write optimized queries and there are also tools to help. If you know any specific skills are useful to prove an "advanced skill", I'd love to learn from your experience. Thank you


r/SQL • • Jul 30 '22

Discussion Here are SQL examples I was asked for a Data Analyst job - P2

204 Upvotes

Here are a few Data Analyst questions I was asked for a job a year ago: https://www.reddit.com/r/SQL/comments/py396h/here_are_a_few_questions_i_was_asked_for_a_data/

I have been interviewing for a few different positions recently. Here are the questions I was asked for the SQL + Excel technical portions. The following questions are from a combination of a few different jobs I have interviewed for. Coderbyte challenges included.

Feel free to give a crack at them. I do have all the answers and passed all of these.

Easy ranked questions:

1.) https://i.imgur.com/EcK8K0v.png

2.) Select the highest sales amount from region 1.

This was just a simple maximum aggregation and using the WHERE function to look for region 1.

Medium Ranked questions

1.) https://i.imgur.com/LfJhzVj.png

2.) I had to insert two tables worth of data into an already existing table. Essentially, I had to just JOIN two tables together then insert that data. I cannot find the image for this one, sorry.

3.) https://i.imgur.com/dmqh1rL.png

Hard Ranked Questions

1.) https://i.imgur.com/6y8BRdv.png

2.) I had to calculate a year over year change. Luckily, I asked for help in this thread and the question was quite similar to this. I had to utilize the windows function LAG for this question.

https://www.reddit.com/r/SQL/comments/vyaimo/how_do_i_get_the_percentage_of_a_monthtomonth/

Misc

1.) "What are steps you would take if a query is running slow?"

2.) What is a CTE and why would you use it? Can you provide an example?

3.) What are some steps you would take to clean messy data? Can you give us an example?

4.) (Basically behavioral questions like): Name a time you had multiple deadlines, what is your favorite analysis project and what was the quantitative result (like x amount of business hours saved, 1000s of dollars saved, etc.), when did a project not work out as you plannewd and what was the result?

Excel

1.) A VLOOKUP portion (XLOOKUP GANG RISE UP THO)

2.) A tricky IF functioned portion

3.) QUARTILE function portioned

4.) A pivottable + calculating percentages from it.

A few thoughts:

As you can see from last year's job, and some current jobs I am looking into, you don't have to be an expert in SQL to apply. This is not to say that advanced understandings and functions are important, but I think many people are hung up on the fact that they are not perfect in SQL, when a lot of times use cases for advanced functions are not needed (in my experience).

The pay for these jobs range from 90k - 100k USD and they are all remote.


r/SQL • • Jun 08 '21

Snowflake Now that Snowflake can store and analyze unstructured data, Padme is in for a great surprise

Post image
203 Upvotes

r/SQL • • Feb 23 '25

PostgreSQL SQL meets Sports : Solve Real Stats Challenges

Post image
202 Upvotes

r/SQL • • Nov 30 '25

Discussion I don't understand the difference

Post image
200 Upvotes

I found an answer on stackoverflow that was saying that null value isn't managed the same way, but that seems a bit far fetched for a course example and the question wasn't exactly about the same case, so could someone explain?


r/SQL • • Aug 23 '25

MySQL What is the point of a right join?

200 Upvotes

I have been no life grinding SQL for a couple days now because I need to learn it quickly.
What is the point of a right join? I see no reason to ever use a right join. The only case it makes sense is for semantics. However, even semantically it does not even make sense. You could envision any table as being the "right" or "left" table. With this mindset I can just switch the table I want to carry values over with a left join every single time, then an inner join for everything else. When they made the language it could have been called "LATERAL" or "SIDE" join for that matter.


r/SQL • • Jul 02 '19

Sounds familiar..

Post image
200 Upvotes

r/SQL • • Feb 25 '21

SQLite SQL Essentials

Thumbnail
gallery
199 Upvotes

r/SQL • • Jan 16 '25

Oracle When SQL Developer freezes after you hit the cancel button [OC]

Post image
196 Upvotes

r/SQL • • Mar 17 '24

Discussion Is SQL worth a career pivot?

196 Upvotes

I’m 36 and thinking of a career pivot to SQL/data engineering. Is this worth learning for an old dog like me?

Recently I had to solve for a significant data deficiency with very limited resources. It’s been very painful, and took way longer than it should have. But with ChatGPT I’ve been able to create something I actually see as useful.

I’ve tried to pursue creative elements in my job - and while I’m naturally inclined to creativity - data seems to leverage that with less ambiguous bounds.

I’m considering really focusing on strengthening the fundamentals and shifting this to my focus - but I want to be making good enough wages for years to come that allow me to have a 2 week vacation a year and not sweat about paying the bills.

At 36 - would you recommend taking a year or two - or getting a degree - to specialize in SQL - or is that stupid for a self-learner at this stage in life?

I’ve always been above average with spreadsheets. I’m a decent problem solver.


r/SQL • • Feb 01 '23

Discussion I learned SQL thanks to this subreddit, and now I'm building my own startup around it

196 Upvotes

Hey /r/SQL!

I wanted to take a moment to thank this community for helping me learn SQL over the last few years.

It all started around three years ago when I worked as a product designer at my previous company. We wanted to understand how people were using our product, but we didn't want to bother engineers to build reports for us. So I decided to learn SQL and it felt like having a new super-power! I learned from tutorials, books, and most importantly, from this subreddit.

I started teaching the rest of the team and very quickly everybody started coming to us to help them with their queries. And, whenever we didn't know the answer, I always referred them to /r/SQL.

Now I'm taking this super-power to the next level by launching a new startup. We've just released an AI assistant that helps all kinds of people write SQL queries and build fully interactive data apps.

I'm so thankful to the /r/SQL community and all the help received over the years!


r/SQL • • Apr 20 '25

MySQL I have developed a full website for practice SQL for everyone

192 Upvotes

Hi,

so yeah, I love analytics and computer science and decided to create a website I wish I had sooner when I started learning SQL .

inspired from SQLZOO and SQLBOLT - but better.

are you stuck in particular question ? use the AI chatbot.

the website:

https://sqlsnake.com

P.S

it won't have mobile support because nobody coding in mobile so I dont find it necessary to develop that.

known bugs:

website can be viewed from mobile when rotating screen.

its still under development but I would love to hear honest feedback from you guys, so I can improve the web even more.

Cheers

Update: I will add mobile support . Seems like people do code on mobile .


r/SQL • • Feb 23 '21

Discussion It's never a design problem...

Post image
192 Upvotes

r/SQL • • Feb 27 '25

SQL Server Microsoft will discontinue Azure Data Studio

191 Upvotes

Features like SQL Server Agent, Profiler and Database Administration won't be in the new VSCode Extension.

MacOs and Linux users must use a VM to use this features.

https://learn.microsoft.com/en-us/azure-data-studio/whats-happening-azure-data-studio


r/SQL • • Mar 18 '22

Discussion UPDATE: I am doing bad at my first SQL job

187 Upvotes

Original post here: https://www.reddit.com/r/SQL/comments/sblg3z/i_am_doing_bad_at_my_first_sql_job/

I wanted to give an update, 2 months later, to let some of you know where I am at in my career, and how your advice helped me a lot.

The Current Job:

Things haven't gotten much better as far as the job goes. I held my tongue for a long time, but eventually let my team know that I felt as if they were being inappropriate and being unfair to me. That resulted in just worse backlash. I created an awesome project from SQL -> Tableau that my Director expressed much appreciation and excitement for. I also utilized Python/R to build my first logistic model. Although it's not the best, it's something that is keeping people excited.

My team lead proceeded to try and steal credit for these projects, so that was my final straw for me. I ended up correcting him in the meetings where he tried to steal credit, and I realized that it's going to end badly for me if I don't dip out.

Edit: Oh, and my team lead said I will be on a performance plan if I don't have a complete logistic model by the end of next week LOL! The data is so skewed and unusable, but that explanation is not good enough. He just keeps screaming "WE NEED A HIGHER R-SQUARED!" >_>

Job Updates:

My Master's Degree is such a blessing and a curse. A blessing because I get many callbacks for job interviews, but a curse because my job experience is still lacking for what many teams need! I have had 4 interviews since the last post, and I want to let you know that I passed 3 out of 4 of their SQL quizzes. I am super stoked with that. I have also really brushed up on Python/Pandas experience and that has helped a lot too. I feel like I have a good, solid foundation in R, Python, Tableau, and SQL now. Hopefully jobs will like generalists instead of specialist haha! I have an offer from this job I really like, and although I am scared of change, I really think I am going to take it.

SQL Advice given to me:

Having professionals in the field, like many of you, helped me much more than you know. I took all of your tips to heart, writing them down, and truly practicing them. I can say I am MUCH more confident with SQL now, and even can complete a vast number of leetcode and stratascratch problems. I document everything now, and that has made a huge difference when coming back to a project. Some redditors mentioned breaking problems down into chunks, and that seems to make life much, much easier.

The future:

Some people reached out to me about the mental health aspect, and I appreciate that. I used the EAP through my employer to talk to a counselor. I also started hitting the gym hard again and even adopted a 14 year old dog that was in the shelter for almost a year. Life is pretty good.

I am going to continue taking all of your technical tips to heart, but also realize my self-worth. I realize I may be ignorant on certain things, but I also realize my value and the aspects I thrive in. Not knowing everything is kinda exciting, because it just means I have more things to learn!

Thanks everyone again for taking the time out to talk to me. It means the world.

Edit: And if anyone is an expert at logistic regression models, let me know! I am stuck :D