Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

get count by weekly pivot table sql server

  SELECT Depots.Name AS 'Depot',  Account.Name, '22/01/2012',  '29/01/2012',  '05/02/2012',  '12/02/2012',
   FROM 
(SELECT Name, 
    FROM Deliveries
    INNER JOIN Account ON Deliveries.Customer = Account.ID
    INNER JOIN Depots ON Account.CollectionDepot) AS Source
PIVOT
(
    SUM(Deliveries.Rates)
    FOR Date IN ('22/01/2012',  '29/01/2012',  '05/02/2012',  '12/02/2012')
) AS 'Pivot Table'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #count #weekly #pivot #table #sql #server
ADD COMMENT
Topic
Name
9+1 =