SQLSQL
#25

Search Query Quality and Poor Query Percentage in SQL

MediumGoogle
Interview Question #25
Asked at Google

Given a `queries` table (query_name, result, position, rating), calculate `quality` as the average of `(rating / position)` and `poor_query_percentage` as the percentage of queries with rating < 3. Round both to 2 decimal places.

Input Table: queries
4 rows preview
query_namepositionrating
Dog15
Dog25
Dog2001
Cat15
Expected Output Structure2 rows
query_namequalitypoor_query_percentage
Dog2.533.33
Cat50
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us