| 1 |
lars |
1 |
FROM_DB FROM_CACHE CACHED AVG_DURATION DURATION_SUM SQL
|
|
|
2 |
1 0 false 0.0315830707 0.0315830707 SELECT
|
|
|
3 |
s.*,
|
|
|
4 |
manager.employeeid AS manager_employeeid,
|
|
|
5 |
manager.employeename AS manager_employeename,
|
|
|
6 |
d.*,
|
|
|
7 |
department_head.employeeid AS department_head_employeeid,
|
|
|
8 |
department_head.employeename AS department_head_employeename,
|
|
|
9 |
e.*,
|
|
|
10 |
sa.*,
|
|
|
11 |
c.*,
|
|
|
12 |
al.*,
|
|
|
13 |
ar.*,
|
|
|
14 |
(SELECT COUNT(*) FROM sale WHERE sale.store_id = s.storeid) AS store_sales,
|
|
|
15 |
(SELECT
|
|
|
16 |
COUNT(*)
|
|
|
17 |
FROM
|
|
|
18 |
sale, employee, employee_department
|
|
|
19 |
WHERE
|
|
|
20 |
sale.employee_id = employee.employeeid
|
|
|
21 |
AND
|
|
|
22 |
employee_department.employee_id = employee.employeeid
|
|
|
23 |
AND
|
|
|
24 |
employee_department.department_id = d.departmentid
|
|
|
25 |
) AS department_sales,
|
|
|
26 |
(SELECT
|
|
|
27 |
COUNT(*)
|
|
|
28 |
FROM
|
|
|
29 |
employee, employee_department, department
|
|
|
30 |
WHERE
|
|
|
31 |
employee_department.employee_id = employee.employeeid
|
|
|
32 |
AND
|
|
|
33 |
employee_department.department_id = department.departmentid
|
|
|
34 |
AND
|
|
|
35 |
department.store_id = s.storeid
|
|
|
36 |
) AS store_employees,
|
|
|
37 |
(SELECT
|
|
|
38 |
COUNT(*)
|
|
|
39 |
FROM
|
|
|
40 |
employee, employee_department
|
|
|
41 |
WHERE
|
|
|
42 |
employee_department.employee_id = employee.employeeid
|
|
|
43 |
AND
|
|
|
44 |
employee_department.department_id = d.departmentid
|
|
|
45 |
) AS department_employees
|
|
|
46 |
FROM
|
|
|
47 |
store s
|
|
|
48 |
LEFT JOIN employee manager ON s.manager = manager.employeeid
|
|
|
49 |
LEFT JOIN department d ON d.store_id = s.storeid
|
|
|
50 |
LEFT JOIN employee department_head ON department_head.employeeid = d.department_head
|
|
|
51 |
LEFT JOIN employee_department ed ON ed.department_id = d.departmentid
|
|
|
52 |
LEFT JOIN employee e ON e.employeeid = ed.employee_id
|
|
|
53 |
LEFT JOIN sale sa ON sa.employee_id = e.employeeid
|
|
|
54 |
LEFT JOIN customer c ON c.customerid = sa.customer_id
|
|
|
55 |
LEFT JOIN album al ON al.albumid = sa.album_id
|
|
|
56 |
LEFT JOIN artist ar ON ar.artistid = al.artist_id
|
|
|
57 |
ORDER BY
|
|
|
58 |
s.storeid,
|
|
|
59 |
manager.employeeid,
|
|
|
60 |
d.departmentid,
|
|
|
61 |
department_head.employeeid,
|
|
|
62 |
ed.employee_id,
|
|
|
63 |
ed.department_id,
|
|
|
64 |
e.employeeid,
|
|
|
65 |
sa.saleid,
|
|
|
66 |
c.customerid,
|
|
|
67 |
al.albumid,
|
|
|
68 |
ar.artistid
|
|
|
69 |
|
|
|
70 |
TOTAL_DURATION: 0.15052819252014
|
|
|
71 |
DB_DURATION: 0.13506817817688
|