Mad SQL query

Report a typo

Once upon a time, we tried to play mad scientist and create an SQL query using a text block. But alas! Our experiment didn't go as planned, and the code refused to compile. Fix the error and display the SQL query on the screen. There must be no empty lines in the output.

Sample Input 1:

Sample Output 1:

SELECT u.username, COUNT(*) as num_posts
FROM users u
JOIN posts p ON u.id = p.user_id
WHERE p.published_at >= '2022-01-01'
GROUP BY u.username
HAVING COUNT(*) > 10
ORDER BY num_posts DESC
LIMIT 10;
Write a program in Java 17
public class Main {
public static void main(String[] args) {
//fix the code below
String querySQL = """SELECT u.username, COUNT(*) as num_posts
FROM users u
JOIN posts p ON u.id = p.user_id
WHERE p.published_at >= '2022-01-01'
GROUP BY u.username
HAVING COUNT(*) > 10
ORDER BY num_posts DESC
LIMIT 10;";

System.out.println(querySQL);
}
}
___

Create a free account to access the full topic