You are given a table, Tasks, containing three columns: TaskId, Start Date and E
ID: 3816696 • Letter: Y
Question
You are given a table, Tasks, containing three columns: TaskId, Start Date and EndDate. Each task requires only 1 day in order to complete. That is, the difference between the EndDate and the Start Date is equal to 1 day (or each raw in the table. If the StartDate of the tasks are consecutive, then they are part of the same project. The projects table, PROJECTS, was accidentally deleted. Write a query to produce a summary table of the projects undertaken. The summary table should include the start and end dates of projects listed by the number of days it took to complete the project in ascending order. If there is more than one project that have the same number of completion days, then output is ordered by the start date of the project. Date: TASKS:Explanation / Answer
SELECT TASKID , STARTDATE, ENDDATE ,DATEDIFF(day,STARTDATE,ENDDATE) AS NO_OF_DAYS_TO_COMPLETE ORDER BY NO_OF_DAYS_TO_COMPLETE , STARTDATE
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.