Pivot on WeekDay Example

0

Please login or register to vote for this query.

(click on this box to dismiss)

Board and Card Games

Q&A for people who like playing board games, designing board games or modifying the rules of existing board games

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

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results