-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript 3.sql
More file actions
59 lines (46 loc) · 1.67 KB
/
Copy pathScript 3.sql
File metadata and controls
59 lines (46 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use org;
-- select
select * from worker;
select salary from worker;
select first_name,salary from worker;
-- dual table
select 55+11;
select now();
select ucase('mitesh');
select lcase('MITESH');
-- where clause
select * from worker where salary > 80000;
select * from worker where department = 'HR';
-- between clause
select * from worker where salary between 80000 and 100000;
-- in clause
select * from worker where department = 'HR' or department = 'admin';
select * from worker where department in ('HR','Admin');
-- Not clause
select * from worker where department not in ('HR','Admin');
-- is null
insert into worker
(worker_id,first_name,last_name,salary,joining_date,department) values
(009,'dhrumit','patel',100000,'14-02-20 09.00.00',NULL);
select * from worker where department is null;
-- wildcard
select * from worker where first_name like '%te%';
select * from worker where first_name like '_ites_';
select * from worker where first_name like '%tesh';
-- sorting / ordering default is asc
select * from worker order by salary ASC;
select * from worker order by salary DESC;
-- distinict
select distinct department from worker;
-- group by
select department from worker group by department;
select department, count(department) from worker group by department;
-- avg salary per department
select department, AVG(salary) from worker group by department;
-- min max sum
select department, MIN(salary) from worker group by department;
select department, MAX(salary) from worker group by department;
select department, SUM(salary) from worker group by department;
-- group by having
select department, count(department) from worker
group by department having count(department) >2;