Find the 10 most popular articles on a blog

Write a SQL query to find the 10 most popular articles on a blog, based on the number of likes.

Problem

Write a SQL query that returns the 10 most popular articles from a blog, based on the number of likes.
Example input:
Article 1: 100 likes
Article 2: 50 likes
Article 3: 30 likes
Article 4: 20 likes
Article 5: 10 likes
Example output:
Article 1: 100 likes
Article 2: 50 likes
Article 3: 30 likes
Article 4: 20 likes
Article 5: 10 likes

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT * FROM articles ORDER BY likes DESC LIMIT 10;

/*

The above solution is optimal because it uses the ORDER BY clause to sort the articles by the number of likes in descending order.
The LIMIT clause is used to limit the number of articles returned to 10.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also efficient, as it uses the ORDER BY and LIMIT clauses to retrieve the desired data.

Evaluated at: 2022-11-09 02:15:59