What does the GROUP BY operator do in SQL?
Anonymous Quiz
3%
Removes duplicates from the result.
77%
Groups rows to apply aggregate functions (like COUNT, SUM, AVG) to each group.
4%
Combines all rows into one.
15%
Sorts data by a specified column.
Which SQL query selects unique values from a column?
Anonymous Quiz
0%
SELECT DIFFERENT column_name FROM table_name;
12%
SELECT UNIQUE column_name FROM table_name;
78%
SELECT DISTINCT column_name FROM table_name;
10%
SELECT DISTINCT * FROM table_name;
What SQL query retrieves the second-highest salary from the employees table?
Anonymous Quiz
2%
SELECT MAX(salary) FROM employees;
16%
SELECT salary FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
2%
SELECT salary FROM employees ORDER BY salary ASC LIMIT 1;
80%
SELECT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 1;
Which of the following commands will delete a table permanently?
Anonymous Quiz
9%
DELETE TABLE table_name;
89%
DROP TABLE table_name;
2%
REMOVE TABLE table_name;
0%
CLEAR TABLE table_name;
How do you generate a new Rails model named Article?
Anonymous Quiz
4%
rails create model Article
5%
rails generate Article
90%
rails generate model Article
1%
rails new model Article
How do you retrieve all users whose name starts with "A" using ActiveRecord?
Anonymous Quiz
77%
User.where("name LIKE 'A%'")
9%
User.find_by(name: 'A%')
4%
User.get_all(name: /^A/)
10%
User.select("name LIKE 'A%'")
What does before_action :authenticate_user! do in a Rails controller?
Anonymous Quiz
3%
Automatically logs in the user
96%
Calls authenticate_user! before executing any action in the controller
0%
Runs only after the controller action
1%
Redirects to the homepage if the user is logged in
1
x = 5
y = 10
x, y = y, x
puts "#{x} #{y}"
The quiz will be in 1 minute
👍3❤1
array = [1, 2, 3, 4]
array.each do |num|
next if num.even?
print num
end
The quiz will be in 1 minute
x = [1, 2, 3]
y = x.map { |n| n * 2 }
x[0] = 10
puts "#{x} #{y}"
The quiz will be in 1 minute
What will be printed when the following code is executed? ☝️
Anonymous Quiz
88%
[10, 2, 3] [2, 4, 6]
3%
[10, 2, 3] [1, 2, 3]
4%
[1, 2, 3] [2, 4, 6]
4%
Error
What will be the output?☝️
Anonymous Quiz
70%
Rescued: Oops\nFrom ensure
16%
Rescued: Oops
9%
From ensure
5%
Error
👎12🤯6
👎13
Forwarded from Ruby Interview | Ruby on Rails
🤯7🤔1