Find Low Quality Problems with a Like Ratio Below 60%

Quick Overview

Write a SQL query that returns the IDs of problems whose share of likes among all votes is strictly below 60%. It tests filtering on a computed ratio, how PostgreSQL divides integers, and correct handling of a strict threshold.

Find Low Quality Problems with a Like Ratio Below 60%

Company: GitHub

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

Each row of the `Problems` table holds the like and dislike counts for one problem. A problem is low quality when its like ratio, `likes / (likes + dislikes)`, is strictly less than 60%. Return the `problem_id` of every low quality problem. ```hint Watch the arithmetic Check what type a division returns when both operands are integers. ``` ### Input Table(s) `Problems` (primary key `problem_id`) | Column | Type | Meaning | |---|---|---| | `problem_id` | INT | Primary key. One row per problem. | | `likes` | INT | Number of likes. NOT NULL. | | `dislikes` | INT | Number of dislikes. NOT NULL. | ### Output Contract - One column: `problem_id`. - One row per low quality problem. - Sort by `problem_id` ascending. ### Example `Problems` | problem_id | likes | dislikes | |---|---|---| | 1 | 60 | 40 | | 2 | 59 | 41 | | 3 | 100 | 0 | | 4 | 0 | 100 | Expected output | problem_id | |---| | 2 | | 4 | Problem 1 has exactly 60% likes, which is not strictly less than 60%, so it is not low quality. Problem 2 has 59% likes and problem 4 has 0%, so both are low quality. Problem 3 has 100% likes. ### Constraints and Clarifications - The table has 1 to 10,000 rows, and `problem_id` is between 1 and 10,000. - `likes` and `dislikes` are non-negative integers and never NULL. - `likes + dislikes > 0` for every row, so the ratio is always defined. - The threshold is strict: a problem at exactly 60% is not low quality. Compare the exact ratio and do not round the percentage first. - `problem_id` is unique, so each problem appears at most once in the result.

Overview: Write a SQL query that returns the IDs of problems whose share of likes among all votes is strictly below 60%. It tests filtering on a computed ratio, how PostgreSQL divides integers, and correct handling of a strict threshold.

GitHub logo
GitHub
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

Each row of the Problems table holds the like and dislike counts for one problem. A problem is low quality when its like ratio, likes / (likes + dislikes), is strictly less than 60%.

Return the problem_id of every low quality problem.

Input Table(s)

Problems (primary key problem_id)

ColumnTypeMeaning
problem_idINTPrimary key. One row per problem.
likesINTNumber of likes. NOT NULL.
dislikesINTNumber of dislikes. NOT NULL.

Output Contract

  • One column: problem_id .
  • One row per low quality problem.
  • Sort by problem_id ascending.

Example

Problems

problem_idlikesdislikes
16040
25941
31000
40100

Expected output

problem_id
2
4

Problem 1 has exactly 60% likes, which is not strictly less than 60%, so it is not low quality. Problem 2 has 59% likes and problem 4 has 0%, so both are low quality. Problem 3 has 100% likes.

Constraints and Clarifications

  • The table has 1 to 10,000 rows, and problem_id is between 1 and 10,000.
  • likes and dislikes are non-negative integers and never NULL.
  • likes + dislikes > 0 for every row, so the ratio is always defined.
  • The threshold is strict: a problem at exactly 60% is not low quality. Compare the exact ratio and do not round the percentage first.
  • problem_id is unique, so each problem appears at most once in the result.