Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. CREATE TABLE [dbo].[Table_1]([Bill_ID] [varchar](20) NOT NULL,[Customer_ID] [varchar](20) NOT NULL,[Bill_date] [date] NOT NULL,[Bill_Amount] [varchar](20) NOT NULL, [Bill_Tax] [varchar](20) NULL, [Create_By] [varchar](20) NOT NULL,[Created_Date] [date] NOT NULL) ON [PRIMARY]
  2. select [Bill_ID],[Customer_ID],[Year],[Bill_Amount],[Bill_Tax],[Create_By],[Created_Date] from (SELECT [Bill_ID],[Customer_ID],DATENAME(month,CONVERT(date,[Bill_date])) AS 'Month Name',DATENAME(YEAR,CONVERT(date,'2016-03-14')) AS 'Year',[Bill_Amount],[Bill_Tax],[Create_By],[Created_Date] FROM [Table_1]) as table2
  3. pivot(
  4. sum([Bill_Amount])
  5. for(select DATENAME(month,CONVERT(date,[Bill_date])) AS 'Month Name')in(January,February,March,April ,May,June,July,August,September,Octobor,November,December)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement