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.
Here is my take on Mysql. Any advice is appreciated.
/* This outer query is only for ordering by project duration */SELECTP3.sd,P3.edFROM(SELECTMIN(P1.Start_Date)ASsd,P2.End_DateASedFROMProjectsASP1INNERJOINProjectsASP2ONp2.End_DateNOTIN(SELECTStart_DateFromProjects)/*we exclude the end dates that exists on Start_Date which means they are part of the same project*/AND/*Once we've found an end date not same as any of the start dates we check backwards how many other cols there are within the same time span count them first if the number equals to the day difference that means they are actually linked. Use "group by" End_date with MIN() to find the earliest start date there is that is linked */(SELECTcount(*)FromProjectsWHEREStart_DateBETWEENP1.Start_DateANDP2.End_Date)=DATEDIFF(P2.End_Date,P1.Start_Date)GROUPBYP2.End_Date)ASP3ORDERbyDATEDIFF(P3.ed,P3.sd),P3.sd;
SQL Project Planning
You are viewing a single comment's thread. Return to all comments →
Here is my take on Mysql. Any advice is appreciated.