Unable to Subtract Dates SQL Server
Using the sample data you posted (and adapting it slightly), here is my attempt to solve the problem: SELECT BASESCORE, Datediff(dd, MINDATE, MAXDATE) FROM (SELECT BASESCORE, Cast(Max(DATETIME) AS DATETIME) MaxDate, Cast(Min(DATETIME) AS DATETIME) MinDate FROM table1 GROUP BY BASESCORE)T You can take a look at the full working version on SQL Fiddle. Let me know … Read more