r/SQL • • Jun 19 '24

Discussion I got rekt in a SQL interview today

Just thought it was hilarious and I wanted to share: I was asked a few very easy SQL questions today during a phone screen and I absolutely bombed two basic ones.

I use SQL every day and have even taught SQL classes, but I never really learned the difference between rank and dense rank because I use neither in dealing with big values(just use row number). I remembered seeing the answer to that question on this very subreddit earlier too, I just didn’t remember it because it was so obscure to me. Curious how y’all have used rank and dense rank.

Also I messed up the default order by direction because my brain apparently no worky and I always type in either “asc” or “desc” out of habit anyway.

SQL trivia shudders

Nightmare for a daily user and sql guy.

435 Upvotes

342 comments sorted by

View all comments

2

u/bad-justin Jun 19 '24

I’ve never heard of rank or dense rank and I rarely encounter raw sql knowledge better than mine. Might not exist in T-SQL? Either way I refuse to learn it now

2

u/kater543 Jun 19 '24

Yeah it seems weird because in person I rarely meet SQL experts but online everyone is one. Maybe we’re just too scattered? LOL. But yeah dense rank and rank seem a bit niche.

2

u/bad-justin Jun 19 '24

It could say something about the position too - I’d love to ask the person asking this interview question when they encountered a situation where knowing the difference or using either provided value to the business that couldn’t be achieved otherwise (to the extent that it’s so important that it’s now an interview question)

2

u/kater543 Jun 19 '24

Great question! If I get to the next stage I’ll be sure to ask.

1

u/EvilGeniusLeslie Jun 20 '24

It's worth learning something new, even if you don't see a use for it now - it may come in handy later.

Decades back (i.e. prior to SQL Server 2005), had to build a org chart for a very large organization (~300K employees), from PeopleSoft, where the relevant table contains Employee Name, Employee ID, Manager ID, and a start date for the relationship.

Ignoring the nightmare where a manager left the company, and there was no entry showing the new employee-manager relationship, it took 14 passes on the table to build the org table.

Had to redo it about eight years back, for another company, where the PeopleSoft generated table didn't have what they wanted.

Recursive CTE, so effin simple to do now.

You don't have to know how to code something, just remember that it exists, and that google is your friend!