Question 11
EasyWhich names does this query return, in order, for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
DBMS
Which names does this query return, in order, for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
SELECT name FROM staff WHERE salary > 45000 ORDER BY name;
John, Ravi, Sara
Sara, John, Ravi
John, Ravi
Ravi, John
Sign up free to see the answer and a step-by-step explanation.
Which departments does this query return for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
SELECT dept FROM staff GROUP BY dept HAVING COUNT(*) > 1 ORDER BY dept;
IT
HR, IT
Sign up free to see the answer and a step-by-step explanation.
What does this query return for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
SELECT AVG(salary) FROM staff WHERE dept = 'HR';
39000.0
38000.0
Sign up free to see the answer and a step-by-step explanation.
What does this query return for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
SELECT SUM(salary) FROM staff WHERE dept <> 'HR';
155000
110000
Sign up free to see the answer and a step-by-step explanation.
What does this query return for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
SELECT name FROM staff WHERE name LIKE 'S%';
Sara
Sara, Sales
Sign up free to see the answer and a step-by-step explanation.
What does this query return for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
SELECT COUNT(DISTINCT dept) FROM staff;
2
1
Sign up free to see the answer and a step-by-step explanation.
What does this query return for the table below?
Table staff:
| id | name | dept | salary |
|---|---|---|---|
| 1 | Ravi | IT | 50000 |
| 2 | Meena | HR | 40000 |
| 3 | John | IT | 60000 |
| 4 | Sara | Sales | 45000 |
| 5 | Ali | HR | 38000 |
SELECT MIN(salary) FROM staff WHERE dept = 'IT';
38000
40000
Sign up free to see the answer and a step-by-step explanation.
Which keyword gives a column a different name in a query's output, as in SELECT salary * 12 ___ annual_pay?
LIKE
NAME
TO
AS
Sign up free to see the answer and a step-by-step explanation.
Which clause filters groups after GROUP BY, using conditions on aggregates such as COUNT(*)?
WHERE
LIMIT
ORDER BY
HAVING
Sign up free to see the answer and a step-by-step explanation.
Which SQL statement changes values in rows that already exist?
INSERT
UPDATE
ALTER
CREATE
Sign up free to see the answer and a step-by-step explanation.
HR, IT, Sales
Sales
78000.0
40000.0
233000
78000
No rows
Meena, Sara
5
3
60000
50000