Sep 8
Sep 8
2. union vs unionall
4.Create a query to display the last name and salary of employees earning more
than 12,000
6.Display the last name and salary for all employees whose salary is not in the
range of 5,000 and 12,000.
7.Display the last name and salary for all employees whose salary is not in the
range of 5,000 and 12,000. Display the last name and department number of all
employees in departments 20 and 50 in alphabetical order by name.
8.List the last name and salary of employees who earn between 5,000 and 12,000, and
are in department 20 or 50. Label the columns Employee and Monthly Salary,
9.Display the last name and hire date of every employee who was hired in 2005.
10.Display the last name and job title of all employees who do not have a manage
11.Display the last name, salary, and commission for all employees who earn
commissions. Sort data in descending order of salary and commissions.
12.Display the last names of all employees where the third letter of the name is
an a.
13.Display the last name of all employees who have an a and an e in their last
name.
14.Display the last name, job, and salary for all employees whose job is sales
representative or stock clerk and whose salary is not equal to 2,500, 3,500, or
7,000.
15.Display the last name, salary, and commission for all employees whose commission
amount is 20.
a =1 2 3 4 5 6 7 8
b = 3 6 7 8 9 10
a union b =1 2 3 4 5 6 7 8 9 10
a union all b =1 2 3 4 5 6 7 8 3 6 7 8 9 10
a intersect b =3 6 7 8
a minus b=1 2 4 5
2. union vs unionall
2. union vs unionall
union - display all records (matched and unmatched )exclude the duplicate records
union all - all records are selected including duplicates
4.Create a query to display the last name and salary of employees earning more than
12,000
5.Create a query to display the employee last name and department number for
employee number
6.Display the last name and salary for all employees whose salary is not in the
range of 5,000 and 12,000.
select last_name,salary from employees where salary not between 5000 and 12000;
7. Display the last name and department number of all employees in departments 20
and 50 in alphabetical order by name.
8.List the last name and salary of employees who earn between 5,000 and 12,000, and
are in department 20 or 50. Label the columns Employee and Monthly Salary
> select last_name Employee, salary "Monthly_Salary" from employees where salary
(between 5000 and 12000) and department_id in (20,50);
9.Display the last name and hire date of every employee who was hired in 2005.
or
10.Display the last name and job title of all employees who do not have a manager.
11.Display the last name, salary, and commission for all employees who earn
commissions. Sort data in descending order of salary and commissions.
12.Display the last names of all employees where the third letter of the name is
an a.
13.Display the last name of all employees who have an a and an e in their last
name.
> select last_name from employees where last_name like '%a' or last_name like
'%e';
14.Display the last name, job, and salary for all employees whose job is sales
representative or stock clerk and whose salary is not equal to 2,500, 3,500, or
7,000.
15.Display the last name, salary, and commission for all employees whose commission
amount is 20.
>
SELECT last_name, salary, commission_pct
FROM employees
WHERE commission_pct =20;
Examples:
Intersect - INTERSECT gives you the rows that are found in both queries by
eliminating rows that are only found in one or the other query.
select employee_id from employees
intersect
select employee_id from job_history;
MINUS operator is used to return all rows in the first SELECT statement that are
not returned by the second SELECT statement
select employee_id from employees
minus
select employee_id from job_history;
WHERE CustomerName LIKE 'a%' Finds any values that starts with "a"
WHERE CustomerName LIKE '%a' Finds any values that ends with "a"
WHERE CustomerName LIKE '%or%' Finds any values that have "or" in any position
WHERE CustomerName LIKE '_r%' Finds any values that have "r" in the second
position
WHERE CustomerName LIKE 'a__%' Finds any values that starts with "a" and are at
least 3 characters in length
WHERE ContactName LIKE 'a%o' Finds any values that starts with "a" and ends with
"o"
Example:
The following SQL statement selects all customers with a City starting with "ber":
SELECT * FROM Customers
WHERE City LIKE 'ber%';
1. Unary +,-
2. Multiply, division
3. +,-,||, concat
4. = , != , > , < ,>= ,<= , is null, like, in, between
5. NOT
6. AND
7. OR
Represent all command with exaplanation and with the given verbose in LMS
20. wc,ls,mv,cp,rm,rm-rf,rmdir,mkdir,cd,cd ..,cd /,cd ~,pwd,touch,info,man
whatis,su, su - ,su - username,change password of any user
ls is a Linux shell command that lists directory contents of files and directories.
mv- moves one or more files or directories from one place to another
cp – for copying files and directories
rm – for removing objects like files directories etc,
rm-rf –removes non emplty files forcefully
rmdir – remove empty directories
mkdir – make directory
cd – change directory
cd ..- change directory to parent directory
cd /- go to home directory
cd ~ - this command is used to change directory to the home directory.
pwd- present working directory
touch – create empty files
info – display information
man – display manual
whatis,
su – system user,
su – root user ,
su - username,- to the mentioned user
change password of any user-passwd