Add SQL Rows with DatePart

0

I have this query that brings me the minutes of each day, however I want to add them all, but it returns me values different:

SELECT  
    DATENAME(WEEKDAY,DateOpen) as Dias,
    SUM(DATEPART(MINUTE, CONVERT(Datetime,MTTA))) as Minutos 
FROM 
    GeneralReport
WHERE
    Week='4'
GROUP BY 
    GeneralReport.DateOpen
    
asked by CarlosR93 26.01.2018 в 21:57
source

1 answer

0

It is that if you want to add by day of week, you must group by that same data (you were doing it by DateOpen )

SELECT  DATENAME(WEEKDAY,DateOpen) as Dias,
        Sum(DATEPART(MINUTE, CONVERT(Datetime,MTTA))) as Minutos 
        from GeneralReport
        WHERE Week='4'
        GROUP BY DATENAME(WEEKDAY,DateOpen)
    
answered by 26.01.2018 / 22:19
source