Skip to content

Commit e793259

Browse files
committed
Section 02 : Basic Join : part 01
1 parent be3f4d2 commit e793259

5 files changed

+22
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
select unique_id, name from Employees as e
2+
left join EmployeeUNI as u
3+
on e.id = u.id
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select p.product_name, s.year, s.price from Sales as s left join Product as p on p.product_id = s.product_id
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select V.customer_id, COUNT(V.visit_id) as count_no_trans from Visits V left join Transactions T on V.visit_id = T.visit_id where T.transaction_id IS null group by V.customer_id
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT w2.id
2+
FROM Weather w1, Weather w2
3+
WHERE w1.recordDate + INTERVAL 1 DAY = w2.recordDate
4+
AND w2.temperature > w1.temperature;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
SELECT
2+
machine_id,
3+
ROUND(AVG(end_time - start_time), 3) AS processing_time
4+
FROM
5+
(SELECT
6+
machine_id,
7+
process_id,
8+
MAX(CASE WHEN activity_type = 'end' THEN timestamp END) AS end_time,
9+
MAX(CASE WHEN activity_type = 'start' THEN timestamp END) AS start_time
10+
FROM
11+
Activity
12+
GROUP BY machine_id , process_id) t
13+
GROUP BY machine_id;

0 commit comments

Comments
 (0)