Last updated
Calculate daily salary of each employee based on login-logout swipe activity and hourly salary rate.
Calculate daily salary of each employee based on login-logout swipe activity and hourly salary rate.
Your dataset contains two employee attendance and compensation tables: 1. A Salary table with employee name and hourly salary rate 2. A Swipe table with login and logout swipe activity timestamps Analyze employee swipe activity and calculate salary earned by each employee on a daily basis.
| Column | Type | Key / Notes |
|---|---|---|
| employee_id | INT | |
| name | VARCHAR(100) | |
| salary_per_hour_$ | FLOAT |
| Column | Type | Key / Notes |
|---|---|---|
| employee_id | INT | FK |
| activity_type | VARCHAR(10) | |
| activity_time | DATETIME |
Salary — 4 rows
| employee_id | name | salary_per_hour_$ |
|---|---|---|
| 1 | Jeremy | 16.78 |
| 2 | Nicole | 25.87 |
| 3 | Naomi | 22.45 |
| 4 | Lyanne | 19.27 |
Swipe — 20 rows
| employee_id | activity_type | activity_time |
|---|---|---|
| 1 | login | 2024-07-23 08:00:00 |
| 1 | logout | 2024-07-23 12:00:00 |
| 1 | login | 2024-07-23 13:00:00 |
| 1 | logout | 2024-07-23 17:00:00 |
| 2 | login | 2024-07-23 09:00:00 |
| 2 | logout | 2024-07-23 11:00:00 |
| 2 | login | 2024-07-23 12:00:00 |
| 2 | logout | 2024-07-23 15:00:00 |
| 1 | login | 2024-07-24 08:30:00 |
| 1 | logout | 2024-07-24 12:30:00 |
| 2 | login | 2024-07-24 09:30:00 |
| 2 | logout | 2024-07-24 10:30:00 |
| 3 | login | 2024-07-24 09:00:00 |
| 3 | logout | 2024-07-24 13:45:00 |
| 3 | login | 2024-07-24 14:30:00 |
| 3 | logout | 2024-07-24 17:30:00 |
| 4 | login | 2024-07-23 10:30:00 |
| 4 | logout | 2024-07-23 15:00:00 |
| 4 | login | 2024-07-23 16:30:00 |
| 4 | logout | 2024-07-23 19:00:00 |
Daily Employee Salary Calculation: What is the total salary of each employee for each working day? The final result table should have name, activity_date, and salary columns.
Your output should look like this (partial example):
| name | activity_date | salary |
|---|---|---|
| Jeremy | 2024-07-23 | 134.24 |
| Jeremy | 2024-07-24 | 67.12 |
| Lyanne | 2024-07-23 | 134.89 |