0% found this document useful (0 votes)
4 views3 pages

SQL Queries for Employee Data Analysis

Sql

Uploaded by

ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

SQL Queries for Employee Data Analysis

Sql

Uploaded by

ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lab Exercise:

1. Find department_id ,last_name and salary whose the salary greater than 3000 and
department_id equal 90 sort the result by employee_id and salary in ascending order .

2. Display job_id , last_name and COMMISSION_PCT for all employees Whose


COMMISSION_PCT is null sorted by job_id in descending order

3. Display last_ name for all employees in which the second letter of the last_name is e
4. Display the first_name and salary ,department_id of all employees who department_id
in 50 or 90 ,200 sort the result in ascending alphabetical order by department_id.

5. Disaplay the first_name who first name started by B .


6. Select the last_name , first_name,salary whose the salary in range 5000 and 120000

Common questions

Powered by AI

The query must filter based on the given department ids using the IN keyword, and then sort the results by "department_id" alphabetically. The SQL query is: SELECT first_name, salary, department_id FROM employees WHERE department_id IN (50, 90, 200) ORDER BY department_id ASC .

To retrieve the desired information, the query would specify conditions to filter employees with a salary greater than 3000 and who belong to department 90. The results will then be sorted by "employee_id" and "salary" using an ORDER BY clause, ensuring the ASC keyword for ascending order. The SQL query would be: SELECT department_id, last_name, salary FROM employees WHERE salary > 3000 AND department_id = 90 ORDER BY employee_id ASC, salary ASC .

To achieve this, the query would filter records having a null value in "COMMISSION_PCT" and then sort them in descending order by "job_id". The SQL query would be: SELECT job_id, last_name, COMMISSION_PCT FROM employees WHERE COMMISSION_PCT IS NULL ORDER BY job_id DESC .

To select employees with salaries within the specified range, a WHERE clause with the BETWEEN operator would be used. The SQL query for this task is: SELECT last_name, first_name, salary FROM employees WHERE salary BETWEEN 5000 AND 120000 .

To display last names where the second letter is 'e', the SQL query should use pattern matching with the LIKE operator. The appropriate condition would specify an underscore for the first character, 'e' for the second, and a percent sign for the remaining characters: SELECT last_name FROM employees WHERE last_name LIKE '_e%' .

To retrieve names starting with 'B', the SQL query would utilize the LIKE operator with 'B%' as the pattern. The SQL query is: SELECT first_name FROM employees WHERE first_name LIKE 'B%' .

You might also like