Back to the 2024 paper

Unit 2: Relational Query Languages

20247m

Write an SQL query to retrieve all employees from an "Employees" table with specific criteria (e.g., department, salary range).

Worked SolutionAI Assisted

SQL query to retrieve employees with criteria (example department='IT' and salary range 40000-60000):

SELECT * FROM Employees WHERE department = 'IT' AND salary BETWEEN 40000 AND 60000;

SELECT emp_id, name, department, salary FROM Employees WHERE department = 'Sales' AND salary > 50000 ORDER BY salary DESC;

With pattern: SELECT * FROM Employees WHERE department IN ('IT','HR') AND salary >= 40000 AND salary <= 80000;

Explain: SELECT chooses columns, WHERE filters rows, BETWEEN for range, AND combines conditions. Can add ORDER BY, LIMIT.

If parameterized: SELECT * FROM Employees WHERE department = ? AND salary BETWEEN ? AND ?;

Similar questions

Database Management SystemConsider the following employee database, primary keys are underlined. Employee (ename, street, city) Works (ename, cname, salary) Company (cname, city) Manages (ename, manager-name) Write SQL queries to (i) Find the names of all the employees who work for XYZ. (ii) Find all employees who live in the same city as the company for which they work. (iii) Find all employees who live in the same cities and on the same streets as do their managers. (iv) Find all employees who earn more than the average salary of all employees of their company.202214mDatabase Management SystemEmployee (ename, street, city) Worksfor (ename, company_name, salary) Company (Company_name, city) Construct the SQL statements for the following (i) Create the above given tables with suitable data types and size. (ii) Find the name of employees who live in the same city where they work. (iii) Find the name of employees who have salary more than Rs. 50000. (iv) Find the name of employees who don't work in "tcs" company. (v) Find all employees whose name has second letter 'A'. (vi) Find the employee's name having second highest salary.20247mDatabase Management SystemConsider: * Student(SID, Name, Dept, Age) * Course(CID, CName, Faculty) * Enroll(SID, CID, Marks) 1. Write relational algebra expressions to find: * a) Students enrolled in DBMS * b) Students scoring >80 marks * c) Students not enrolled in any course 2. Write SQL queries: * a) Find highest marks * b) Find average marks department-wise * c) Display students enrolled in more than two courses 3. Translate the following query into tuple relational calculus: * "Find names of students from CSE department." 4. Convert the following relational algebra into SQL: * \pi_{Name}(\sigma_{Marks > 85}(Student \bowtie Enroll))202510mData MiningWrite an SQL query that runs on the schema designed in Q4a and returns the average SGPA of boys from the State of Karnataka for each Autumn (odd) semester during the years 2005–2009.20214m
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.