0% found this document useful (0 votes)
38 views6 pages

Sep 8

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

Sep 8

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

1.

review topic SQLoperator from LMS

2. union vs unionall

3. create a table named test same copy of employees table .

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.

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.

16. union all vs minus

17. intersect vs minus

18. wild cards in LIKE operator

19. operator precedence


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

21. Linus directory usage :


/home,/etc,/,/root,/bin/sbin,/media,/mnt,/tmp,dev

22. /bin vs /sbin


23. /home vs /etc
================================================================
1. review topic SQLoperator from LMS

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

3. create a table named test same copy of employees table

drop table test;


create table test as select * from employees;

4.Create a query to display the last name and salary of employees earning more than
12,000

SELECT last_name, salary


FROM employees
WHERE salary > 12000;

5.Create a query to display the employee last name and department number for
employee number

// To get the runtime input:

drop table test ;


create table test as select * from employees;
select last_name, department_id from test where employee_id = &a;

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.

> select last_name,department_id from employees where department_id in (20, 50)


order by last_name;

> select last_name,department_id from employees where department_id in (20, 50)


order by 1;

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.

> select last_name,hire_date from employees where


to_char(hire_date,'yyyy')='2005';

or

> select last_name, hire_date


from employees
where hire_date like '%05';

10.Display the last name and job title of all employees who do not have a manager.

> select last_name,job_id from employees where manager_id is null;

11.Display the last name, salary, and commission for all employees who earn
commissions. Sort data in descending order of salary and commissions.

> Select last_name,salary,commission_pct


from employees
where commission_pct is not null
order by salary desc,commission_pct desc;

12.Display the last names of all employees where the third letter of the name is
an a.

> SELECT last_name FROM employees WHERE last_name LIKE '__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.

>select last_name, job_id, salary from employees where (job_id = 'SA_REP' or


job_id='ST_CLERK') and salary not in(2500,3500,7000);

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;

16. union all vs minus

union all - all records are selected including duplicates.


Minus : return distinct rows that are returned by the first query but not returned
by the second query
it gives the result of 1st select statement minus the result of 2nd
select statement
No of columns and datatype of the columns selected must be same.

Examples:

select employee_id from employees


union all
select employee_id from job_history;

select employee_id from employees


minus
select employee_id from job_history;

17. intersect vs minus

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;

18. wild cards in LIKE operator

Wildcard characters are used with the LIKE operator.


The LIKE operator is used in a WHERE clause to search for a specified pattern in a
column.

LIKE Operator Description

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%';

19. operator precedence


paranthese - 1st
same precedence are evaluated from Left to Right
all set operator have equal precedence

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

wc - print the no of bytes , words and lines n files


-c for bytes ;
-m for chars;
-l for lines
-L for max line length
-w for words

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

21. Linus directory usage :


/home,/etc,/,/root,/bin/sbin,/media,/mnt,/tmp,dev

/home- home directory


/etc – most of the configurstion files is in this directory
/ - root
/root – roots home directory
/bin – essential user binaries
/sbin- essential system binaries

/media- contains sub directories for mountpoints

/mnt- non removable media

/tmp- to store temporary data

dev- device files either attached or virtual

22. /bin vs /sbin

bin for users and sbin for system

23. /home vs /etc

home directory ,etc store configuration files

You might also like