guilhermedom / sql-challenges-hacker-rank

MySQL solutions to HackerRank's SQL challenges.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL Challenges HackerRank

This is a repository for MySQL 8.0 solutions of all HackerRank SQL challenges, from easy level to hard.

Coding and Formatting Details

  • Each challenge has a unique .sql file named after the name of the challenge. The problem description given for challenges are provided at the first lines of each .sql file to help readers get a notion about the challenge. Note that challenges also have input and output descriptions and 1 sample test case. Those are not included here to save space, and they are easily available on challenge statements at HackerRank's SQL page;

  • More complex solutions, or solutions that need any sort of insight, have comments explaining them;

  • As queries are not very long, aliases are only used when necessary and consist of acronyms or simple names;

  • This repository is supposed to be used only as a reference for SQL challenges' solutions. Avoid copying code from here;

  • Portability and runtime are not evaluated in HackerRank's online judge. Because of this, queries are not optimized for speed nor generality, but for providing readable solutions in MySQL. However, most solutions provided in this repository should work for other RDBMS, such as Oracle SQL and Microsoft SQL Server.

Solution Warnings

  • These solutions are for MySQL version 8.0.20. Older versions (especially 5.+ or earlier) may not behave as expected or may not have some SQL statements available (i.e. WITH);

  • Some solutions given in here may be encountered on coding interviews, however, this is not a guide.