Pivot on WeekDay Example


Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

SELECT owneruserid, 
FROM   (SELECT score, 
               Datename(weekday, creationdate) DAY 
        FROM   posts 
        WHERE  owneruserid IN ( 1, 2, 3, 4, 5 )) p PIVOT ( SUM (score ) FOR DAY 
       IN ( 
       [Monday], [Tuesday], [Wednessday], [Thursday], [Friday]) ) pvt

Enter Parameters

Switch to main site
loading Hold tight while we fetch your results