Leetcode Problem 2298. Tasks Count in the Weekend

2298. Tasks Count in the Weekend

Leetcode Solutions

Using WEEKDAY Function

  1. Use the WEEKDAY function to get the day index for each submit_date.
  2. Use conditional aggregation with SUM to count the number of tasks submitted on weekends (where WEEKDAY(submit_date) is 5 or 6).
  3. Similarly, count the number of tasks submitted on working days (where WEEKDAY(submit_date) is between 0 and 4).
  4. Return the counts as weekend_cnt and working_cnt respectively.
erDiagram
    Tasks {
        int task_id PK
        int assignee_id
        date submit_date
    }

Using DAYOFWEEK Function

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...