Selecting Data
Which SQL statement would you use to retrieve the names of employees who work in the 'Sales' department?
- SELECT name FROM employees WHERE department = 'Sales';
- SELECT department FROM employees WHERE name = 'Sales';
- SELECT name FROM Sales WHERE department = 'employees';
- SELECT employee_name FROM employees WHERE department = 'Sales';
- SELECT names FROM employees IF department = 'Sales';
Aggregate Function
To find the average salary in each department, which function would you use in your SQL query?
- AVG()
- SUM()
- COUNT()
- MINIMUM()
- MEAN()
Using JOINs
If you want to get order details along with the customer name, which type of JOIN should connect the 'orders' and 'customers' tables?
- INNER JOIN
- CROSS JOIN
- LEFT OUTER JION
- OUTER JION
- FULL INER JOIN
Subqueries
Which of these SQL statements uses a subquery to find employees earning more than the average salary?
- SELECT name, salary FROM employees WHERE salary u003E (SELECT AVG(salary) FROM employees);
- SELECT AVG(salary) FROM employees WHERE salary u003E average;
- SELECT name FROM employees WHERE salary = ALL (salary);
- SELECT name WHERE salary u003E AVG(salary) FROM employees;
- SELECT * FROM employees HAVING salary u003E AVG(salary);
Filtering with IN
Which SQL query would you use to find names of employees who work in the 'HR' or 'Finance' departments?
- SELECT name FROM employees WHERE department IN ('HR', 'Finance');
- SELECT name FROM employees WHERE department = ('HR', 'Finance');
- SELECT name FROM employees WHERE department LIKE 'HR' OR 'Finance';
- SELECT name FROM employees WHERE department IS ('HR', 'Finance');
- SELECT name FROM employees WHERE department IN 'HR', 'Finance';
Combining Results
Which keyword combines results from two queries and removes duplicates, such as selecting employees from 'Marketing' and 'IT' departments?
- UNION
- MERGE
- COMBINE
- JOIN
- INION
Conditional Output
If you want to classify salaries as 'High' for values above 50000 and 'Low' otherwise, which SQL keyword should you use?
- CASE
- SWITCH
- DECISION
- WHEN
- IFTHEN
Grouping and Filtering
How do you filter groups in a GROUP BY query to only include those where the average salary is over 60000?
- By using HAVING AVG(salary) u003E 60000
- By using WHERE AVG(salary) u003E 60000
- By adding FILTER AVG(salary) u003E 60000
- By including LIMIT AVG(salary) u003E 60000
- By using SORT AVG(salary) u003E 60000
Common Table Expressions
What keyword is used to define a Common Table Expression (CTE) in SQL for a temporary result set?
- WITH
- TEMP
- NEWTABLE
- BEGIN
- DEFINE
Updating Data
To increase all salaries in the 'Sales' department by 10%, which command will correctly update the salary values?
- UPDATE employees SET salary = salary * 1.10 WHERE department = 'Sales';
- UPDATE employees ADD 10% TO salary WHERE department = 'Sales';
- UPDATE employees SET salary = salary + 0.10 WHERE department = 'Sales';
- UPDATE employees WHERE department = 'Sales' SET salary = salary 1.10;
- UPDATE employees salary = salary * 10% WHERE department = 'Sales';