Search
 
SCRIPT & CODE EXAMPLE
 

SQL

change date in pivot table to month in sql server

SELECT *
FROM (SELECT YEAR(SalesDate) [Year], 
       DATENAME(MONTH, SalesDate) [Month], 
       COUNT(1) [Sales Count]
      FROM #Sales
      GROUP BY YEAR(SalesDate), 
      DATENAME(MONTH, SalesDate)) AS MontlySalesData
PIVOT( SUM([Sales Count])   
    FOR Month IN ([January],[February],[March],[April],[May],
    [June],[July],[August],[September],[October],[November],
    [December])) AS MNamePivot
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql allow connection from any host 
Sql :: how to select only a certain date sql 
Sql :: sql: extract day text from datetime value 
Sql :: mysql select non integer values 
Sql :: sql subquery 
Sql :: find duplicates in column sql 
Sql :: drop table oracle 
Sql :: sql is not like 
Sql :: alter table name including schema 
Sql :: sql replace null values with another column 
Sql :: to_sql pandas 
Sql :: sql xor 
Sql :: incorrect datetime value sql table error 1292 
Sql :: psql owner of database 
Sql :: how to output a different column name in mysql 
Sql :: sql server function to calculate a percentage 
Sql :: how to add amount between date in sql 
Sql :: float vs decimal sql 
Sql :: mysqlimport 
Sql :: get last date join sql 
Sql :: not in sql 
Sql :: SQL SELECT AS Alias 
Sql :: query params sql insert python f string 
Sql :: varchar2 length in oracle 
Sql :: sql delete where x or y or z 
Sql :: recursive query herarchical data sql server 
Sql :: sort by 
Sql :: SQL Primary Key single column 
Sql :: prestashop alter table if not exists 
Sql :: sql agent jb is enabled query 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =