-
Notifications
You must be signed in to change notification settings - Fork 349
Expand file tree
/
Copy pathTemp_Tables
More file actions
44 lines (29 loc) · 727 Bytes
/
Temp_Tables
File metadata and controls
44 lines (29 loc) · 727 Bytes
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
Create table #temp_employee2 (
EmployeeID int,
JobTitle varchar(100),
Salary int
)
Select * From #temp_employee2
Insert into #temp_employee2 values (
'1001', 'HR', '45000'
)
Insert into #temp_employee2
SELECT * From SQLTutorial..EmployeeSalary
Select * From #temp_employee2
DROP TABLE IF EXISTS #temp_employee3
Create table #temp_employee3 (
JobTitle varchar(100),
EmployeesPerJob int ,
AvgAge int,
AvgSalary int
)
Insert into #temp_employee3
SELECT JobTitle, Count(JobTitle), Avg(Age), AVG(salary)
FROM SQLTutorial..EmployeeDemographics emp
JOIN SQLTutorial..EmployeeSalary sal
ON emp.EmployeeID = sal.EmployeeID
group by JobTitle
Select *
From #temp_employee3
SELECT AvgAge * AvgSalary
from #temp_employee3