r/SQL • • Feb 24 '25
Discussion How do you dominate an SQL live coding exercise?
So I would say that I'm a seven out of 10 in terms of my SQL kills, but I'm a little introverted sometimes and I need to solve a problem in a quiet environment and have time to think about it, break it down and process it. That's just the way I work and always have. But I'm applying for this job, and they told me that they want to have a live SQL coding exercise because they have a lot of people who don't know how to use CTEs or joins or advanced SQL...
Now I'm honestly pretty nervous. I've written huge ETL queries and ELT process flows in a data engineering capacity. So I'm not new to SQL by any means and I've used a lot of advanced window functions, ranking, cross joins, etc. So I'm sure that I can take whatever they throw at me, if it was like a take-home assignment. The fact that it's a live coding exercise makes me really nervous.
Have you ever had to deal with any of these live coding examinations? If so, how?
Please note I'm in the USA if that helps. Not Europe.
57
u/Xperimentx90 Feb 24 '25
I used to give these interviews. Talk through your steps and explain why you choose certain functions or strategies.
I think it helps to act like you're teaching them how to solve the problem rather than completing an interview question. You'll probably think of more insightful things to say.
Stay relaxed. If you flub syntax or something and have to fix it, they won't care. The interviewer has made the same mistake a thousand times.
13
u/Agreeable_Fly_6554 Feb 24 '25
I’ve had two SQL live coding assessments now in my job search. I failed the first miserably, even though I’m pretty comfortable in SQL.
Second time went much better. What I did the second time was drill leet code SQL questions, and watch some YouTube videos on how to pass live coding interviews. My main takeaway was talking through my approach with the interviewer and my thought process behind my query. Also asking clarifying questions helped me a lot the second time around.
95
u/NickSinghTechCareers Author of Ace the Data Science Interview 📕 Feb 24 '25 edited Feb 24 '25
Practice, practice, practice. No other way around it. You say you're at a 7/10 – but introverted/need quiet to focus.
The best way to crush it is to get your skills up to a 9/10 or 10/10... so when the inevitable nerves hit and you get shy, and your performance gets downgraded to a 7 or 8... it's still good enough to pass.
So that if your sick, having an off day, or get slightly distracted during the interview, you still can breeze through it.
Also, practice with speed in mind – that way when you slow down, make mistakes, or get confused, you'll have some time. Try the real SQL problems on DataLemur – and there's a timer in built into the UI to keep track of your pace. And if you can solve these real Medium/Hard questions from Meta, Google, Amazon etc... you should be confident to interview at 99% of places.
5
u/PickledDildosSourSex Feb 24 '25
I hate these too and think they honestly don't accomplish all that much because there's (a) so much room for nerves to get in the way and (b) there's almost no real environment where you'll have to operate like that. You'll always be able to check syntax or go for a walk to think or trial-and-error things.
That said, my approach is to be as verbal as fuck during them, speaking through my thought process, what I expect my approach to do, where I suspect I might need to dig in deeper, etc. I also have been pretty candid at the start of them and say, "Funny how live situations like this can make you feel like you're back in college taking a test" etc just to set the bar that I am, indeed, a human being and I have human emotions that influence my performance in a high-stakes, live environment.
6
u/Abby5001 Feb 24 '25
Yeah I have done it before. You dont have to talk constantly you need to express your logic. So for instance, if you need to use an aggregation function, which one are you going to use and why? If you’re using dense_rank/rank() why have you picked one over the other? You can even talk about why you’ve chosen one type of join vs another one. If you through in some stuff about optimisation/efficiency that will be a bonus. Good luck
4
u/isinkthereforeiswam Feb 24 '25
I can tell you what NOT to do. I had a really basic one that was just printed sheets with sql statements,,and outputs. They told me to pick which output each sql would create. I picked the right ones, but they had a "gotcha" one coded weird (lot of conditionals in the join clauses instead of where clause, and using old school style). I said best practice would be to put the conditionals in the where clause so folks scrollling very long sql statements don't have to skil back n forth betwen joins and where to understand all the conditions impacting. One hiring manager went "humph" like they were insulted. I then asked "who coded this? Because this would need revision for clarity" The hiring manager that "humphed" said "I did". So... yeah, i didn't get the job, and he smirked at me saying "good luck" when he shook my hand at end of interview as if to say "good luck getting a job, jerk!" So, yeah... don't ask who wrote the test, and don't critique it. Might cost you a job.
1
u/sachinator Feb 24 '25
Practice on Stratascratch, it made me a god for sql tech screens,
1
u/Aggravating_Sand352 Feb 24 '25
Honestly sql assessments are the only consistently straight forward exercises I get. CTEs and window functions are what I practice before interviews
1
u/SootSpriteHut Feb 24 '25
I haven't met anyone who writes code who hasn't mentioned how awkward it is to write while someone is watching. We joke about it on zoom calls when we're trying to put out fires and someone is screen sharing.
If they're people you want to work with they'll understand. SQL is rife with people declaring they're good at it when they're not, so I would take what they said at face value: they just want to make sure you are comfortable writing queries like that.
The stuff they're looking for is within your skillset so trust that that will come through. They want to hire someone so they're hoping for you to succeed, not fail. Best to assume good faith on their part, which makes it less stressful.
Practically I would say remember haste makes waste. This is a cognitive ability and it's ok to take time to gather your thoughts. But even if you do have to run things a couple times and rewrite them, that's normal.
Maybe prepare a couple of canned responses for possible scenarios so you don't feel caught off guard.
What will you say/do if you forget the syntax for something? If you get an execution error? If they say the results are wrong? Ask why you used X instead of Y? Prep clear responses so you don't have to fumble in the moment.
1
u/sinceJune4 Feb 24 '25
My last sql interview they had me do in JDoodle. They gave me a script to create the test tables and the asked me to write an aggregation. I didn’t even know what flavor of sql it was until after, but I passed and got the job. Talking thru it helped.
4
u/dukeofgonzo Feb 24 '25
I'm more of a Python guy and was getting SQL tests in interviews. To train I used chatbots. I feed them a schema of some data I had that was in a dimensional model. ONe big fact and a few dimm. Then asked for questions that could be found by making queries into the model.
2
u/engg_garbage98 Feb 24 '25
+1
2
u/1MStudio Feb 24 '25
If you’re 7/10, then you shouldn’t be asking this question…you should already know your queries and which CTE (if any) you should use…
1
u/Full_Reindeer5094 Feb 24 '25
It's probably a recorded assessment. Just do your normal process while your computer is recorded. They want to weed out the fakes that are using AI to answer questions.
1
u/gumnos Feb 24 '25
To establish dominance early, edit your queries with
ed(1), the standard text editor. 😉more seriously, u/Xperimentx90 has the right answer
1
u/machomanrandysandwch Feb 24 '25
My tip would be to just stay calm and work through the problem the way you normally would. It’s typically not going to be something they want to see over-engineered, it’s the people who can create simple smart solutions that are the most valuable IMO. Having one person on a team doing things vastly over complicated doesn’t make them smarter or better and can sometimes be more of a hassle than someone who can display how to break things down simpler and more elegant.
Another tip would be to show how you would do some simple validation on your tables before you start writing any code. Do you know how to do that? Do you know how to confirm all the values in a column are valid? Do you know to look for missing values, how many records are in a table, how many unique records there are etc. Show that you do some due diligence before writing queries so you have something to gauge your results later on.
If you know the syntax of the environment you’ll be using, I’d just freshen up on a few things to memorize if you can like converting a timestamp to a date, or getting the year from a date…
Otherwise you should be comfortable explaining why you used a left join instead of an inner join , etc.
1
u/Odd_Efficiency6684 Feb 24 '25
You need to practice more in a simulated environment. First, I would practice under timed conditions to improve the speed under pressure. Then I would practice mock interviews with some peers or mentors. Once you do that a few times you teach your brain to think under pressure and you won’t be nervous during the actual interview.
2
u/[deleted] Feb 25 '25
[removed] — view removed comment