SQL Judge

Supported Databases

Database Version
PostgreSQL PostgreSQL 9.5
SQL Server SQL Server 2014
Oracle Database Oracle Database 11g


Legend Explanation Icons
RE Execution Failed/Runtime Error
CV Constraints Violated

How does the judge work?

When you submit your query, we do the following:

  1. Setup a new database

  2. Create tables

  3. Load data specified in the test case

  4. Execute your query on the newly set up database and compare the result with expected output

If the output matches the expected result, then it is considered to be an Accepted Submission (AC).

If the output does not match the expected result, then it is considered to be a Wrong Answer (WA).

For more information about various output results, see the LEGEND section.

How does online judge determines whether the solution is correct?

Your code is automatically tested by a HackerEarth SQL service and not by a human being. Therefore, you must write your code accordingly. Each problem will have the following:

  • One or more input files each of which will be according to the specifications mentioned in the problem statement Corresponding correct output files
  • Your program is run on each of those input files. To be judged as a correct submission, the output that is generated by your queries must match the output in the correct output files. Therefore, ensure that your statements are in order.


  • Your output files must match the output files of the problem statement. It does not matter at what point in the program execution the output is written.
  • It is recommended that you do not read all of the input before starting the output. Instead, you can print out each result as you are reading through the input.

Your code will not be judged as a correct submission in the following scenarios: - If your queries start by echoing “Enter the number” and the problem statement does not tell you to do so. Since this is not a part of your correct output, your script will not be judged as a correct submission irrespective of what the rest of your queries do. - If you use a method other than using the standard input and output streams, for example, using command line arguments, reading from a file, opening up a dialog box, etc., your code will not be judged as a correct submission.

How does the total execution time work?

Total execution time <= (time limit*number of input files). Your queries are tested multiple times with different data in the tables. The execution time that is displayed is the total time spent in executing your queries against the database collectively. While processing an input file, if the execution exceeds the time limit (mentioned in the problem), then your queries are terminated.

What are the problem constraints?

Your queries are constrained in following ways:

  • Maximum Tables per Database is constrained. You can only create tables up to the number that is specified in the problem.
  • Maximum Rows per Table is constrained. You can only insert rows up to the number that is specified in the problem.
  • Your queries collectively have a hard time limit of 5 sec.

Why does my program give CV?

Your queries violated one of the above constraints mentioned.

TLE means my code is correct but slow, right? Why do I get Time Limit Exceeded?

No, TLE means that your solution has exceeded the amount of time that was determined for the problem or for a specific test case. Your solution never finished running in time because it was stopped in between. Therefore, there is no definite way to say whether the code is correct or not.

TLE could also mean the following:

  • Your SQL script may contain “sleep” and your queries will stop executing.
  • Your code will terminate, but not within the time limit indicated. For example, if the time limit of an SQL script is 2 seconds and your script terminates on 2.001 seconds, it does NOT mean that it exceeded the limit by 0.001 seconds. It means that the judge stopped evaluating your code after 2 seconds.

What is Wrong Answer (WA)?

WA means that your script ran successfully but the answer was incorrect. This could either be because your SQL script contains a bug or you are not interpreting the problem statement correctly. Your code may pass the sample input correctly, however your SQL script still needs to be evaluated against multiple input and output cases. Therefore, despite passing the sample input cases, you may still get a wrong answer if your output does not match the corresponding correct sample output.

I keep getting various types of runtime errors. What am I missing?

A runtime error means that the program was compiled successfully but it exited with an error or crashed. You will receive an additional error message. The most common runtime errors include the following:


This error means your query execution failed.

You can avoid this error by ensuring the following:

  • Your queries are syntactically correct.
  • Your script is not violating any of the problem constraints.


This error means you have violated one of the problem constraints. The most common reasons for this error are as follows:

  • You have created too many tables.
  • You have inserted too many rows inside a table.

Max number of tables and Max number of rows per table are restricted.

Can I view another developer's solutions?

No, you cannot. Similarly, nobody can view your solutions either.

Why is my submission queued?

Many users may be submitting code simultaneously, due to which, processing will take time. However, your code is in queue and you and you will receive the result of your submission as soon as it is evaluated.

Sometimes our code-checker servers or web servers may be under maintenance. As soon as the maintenance is complete, your submissions will be evaluated.

The submissions are not getting evaluated, what should I do?

There may be an issue with the judge. Contact the website admin immediately by sending an email to either vivek@hackerearth.com or arjit@hackerearth.com.

How can I share my code?

Ideally you should not share your code. During a contest if your code becomes public, then your account can be suspended, if detected for plagiarism.

What do I do if I have queries that are not answered here?

If you think that a problem has incorrect test data, its specification isn't clear or in your opinion something in the problem needs clarification, then post a comment on the problem page.

While posting comments, ensure the following:

  • Do NOT spam.
  • Do not post any source code including your wrong solution or an accepted solution.

Note: Admins/Moderators are allowed to delete the comments.

If you have any more queries, send us an email to support@hackerearth.com.

View All Notifications