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.
Text blocks
Mad SQL query
Report a typo
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);
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.