-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15_sum_min_max_avg_stdev_count.sql
63 lines (48 loc) · 1.18 KB
/
15_sum_min_max_avg_stdev_count.sql
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
60
61
62
63
--[dbo].[employee]
--sum
--minimum
--maximum
--standard deviation
--average
--count
select * from employee
--sum
select sum(SALARY) as total_compensation
from employee
--total_compensation by department
select DEPT_NAME,sum(SALARY) as total_compensation
from employee
group by DEPT_NAME
--MINIMUM
--minimum salary given by the company?
select min(SALARY) as min_salary
from employee
select DEPT_NAME,min(SALARY) as min_salary
from employee
group by DEPT_NAME
--maximum
--maximum salary given by the company?
select max(SALARY) as max_salary
from employee
select DEPT_NAME,max(SALARY) as max_salary
from employee
group by DEPT_NAME
--STANDARD DEVIATION
select round(stdev(SALARY),2) as std_deviation
from employee
select DEPT_NAME, round(stdev(SALARY),2) as std_deviation
from employee
group by DEPT_NAME
--average
--find average salary offered by the company?
select avg(SALARY) as average_salary
from employee
select DEPT_NAME, round(avg(SALARY),2) as average_salary
from employee
group by DEPT_NAME
----count
select count(*) as row_count
from employee
select DEPT_NAME, count(*) as row_count
from employee
group by DEPT_NAME