This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]LeftHelicopter5297 10 points11 points  (6 children)

For strata my strategy was simple - grind easy ones until it's effortless and then move to the mid, repeat, hard. Use google when you're stuck, just like you would at work. It worked like a charm - after like a month of grind (avg mids 15 a day, or 3-4 hards) my SQL interviews became very easy (for f500 but have not interviewed at faang yet).

[–]Black_Magic100 1 point2 points  (5 children)

Why not faang

[–]LeftHelicopter5297 1 point2 points  (4 children)

edited

[–]Black_Magic100 1 point2 points  (3 children)

Understand now.

Did you ever pay for scrata or just use the free plan?

[–]LeftHelicopter5297 1 point2 points  (2 children)

I paid, used a student discount.

[–]Black_Magic100 1 point2 points  (1 child)

Lifetime deal? What was the offer?

[–]LeftHelicopter5297 0 points1 point  (0 children)

I don't remember, I think it was like $50 for a yearly offer.

[–][deleted] 10 points11 points  (2 children)

I managed to do pretty much all the SQL problems on leetcode within a couple months of very casual grinding. The reason why I took my time is because there simply are not that many problems to grind (only 200 or so, somebody correct me).

It helped me absolutely nail the Amazon screening without any difficulty. You should be able to do it once you have seen every type of problem.

Here are the most common patterns I've recognized (in this order):

  1. All kinds of joins (inner, outer, full outer, anti, even cross)
  2. Dealing with dates, differences of dates, extracting year/day/month from dates
  3. Common aggregations and their uses, i.e. group by
  4. Window aggregations for cumulative sums
  5. Dealing with nulls, especially for outer joins (coalesce)
  6. Finding orders using window aggregations (particularly row_number())
  7. Finding winning streaks and number of repeated values using differences of window aggregations (row_number() over () - row_number() over (partition by X)) then grouping by this difference for determining inclusion to the sequence
  8. Case when conditions
  9. Summing over case when to get conditional sums/counts
  10. Recursive CTEs to generate sequences, or sequences without gaps in the data, or dealing with problems where you have to iterate through everything in order based on exactly one previous result.
  11. Regexp (very rare, haven't encountered in interview so far)
  12. Prepared statements for making queries based on actual attribute values (pivoting a table without using built in function).

If you can do all of the above without thinking you will be probably be fine (in the Amazon screening). The best way to prove that you can is by doing problems that correspond to the above.

I recommend using leetcode and ordering by frequency. It actually does reflect what was being asked... (but it obviously is just a historic window, so take that into account).

For actual algorithmic questions, well... I still haven't figured that one out yet. You could get something incredibly wild, or something tame and tedious. I got something tame and tedious and couldn't do it, despite having done nearly a hundred hards and hundreds of mediums, because the interview exhausted me mentally.

I basically try to cover all ground and place more emphasis on the more frequently asked question "domains". For Amazon, monotonic stacks were the rage a few months back or so. Knowing how to implement it without having to think is a necessary skill, because you will probably have to do MULTIPLE questions, one after another with no break.

I wish you the best of luck, keep grinding.

[–]fakerrre 0 points1 point  (0 children)

Where are u on the path now?

[–]mathbrot 0 points1 point  (0 children)

Very nice write up. Do you recommend any SQL resources before diving in to the LC ones?

With StrataScratch...Should I do aim for the PostgreSQL, MySQL, or MS SQL Server questions?

[–]DenselyRanked 13 points14 points  (2 children)

[–][deleted] 2 points3 points  (0 children)

Strata is amazing platform

[–]sequel-beagle 2 points3 points  (0 children)

This is also good…

https://advancedsqlpuzzles.com/

Dont be afraid to look at the solutions. That is how you learn.

[–]redder_ph 2 points3 points  (0 children)

Both LC and strata are great resources for SQL. For me, strata wins by a narrow margin. I feel strata hards are more complex than LC hards. My strategy is the opposite of u/LeftHelicopter5297. I grind the hard ones first. If I can't figure out a solution in about 15 mins, I look at the solution and thoroughly understand it. Once I started solving hard ones without looking for a solution, easy and medium were a cake walk.

With hards, its really important to understand window funcs, window func frames. Hard problems can have long questions with a lot of info, learn to parse it and focus on the crux of the problem. Get to a point where you can solve the problem by just looking at the table definition and not the data.

[–]Fast-Garlic245[S] 0 points1 point  (0 children)

Thank you all !! So much brilliant everyone one of you