We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
/*The difference between end and start date is equal to 1 day for each row If end date tasks are consecutive, then they are in the same project Interested in the total number of different projects completed Output start and end dates of projects listed by number of days it took to complete the project in ASC order. If Conscutive by one day, its another day added to the projectIF more than one project has the same number of completion date, order by start of the project */WITHCTEAS(SELECTStart_Date,End_Date,DATEDIFF(day,ROW_NUMBER()OVER(ORDERBYStart_DateASC),Start_Date)ASProject_IdentifyerFROMProjects)SELECTMIN(Start_Date),MAX(End_Date)FROMCTEGROUPBYProject_IdentifyerORDERBYDATEDIFF(DAY,MIN(Start_Date),MAX(End_Date))ASC,MIN(Start_Date);
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
SQL Project Planning
You are viewing a single comment's thread. Return to all comments →
MS SQL Server