Create a table
CREATE TABLE [dbo]. [Chexin] ([f_id] [int] IDENTITY () not Null,[yuefen] [int.] not NULL,[1] [int] not NULL,[2] [int.] NOT NULL,[3] [int.] not NULL,[4] [INT] Not NULL,[5] [int.] NOT NULL,[6] [int.] NOT NULL,[7] [int.] NOT NULL,[8] [int.] NOT NULL,[9] [int.] NOT NULL,[10] [int.] Not NUL L,[11] [int] not NULL,[12] [int.] not null,[name] [varchar] (a) not null,[gender] [varchar] (a) not NULL, CONSTRAINT [Pk__c HEXIN__2911CBED571DF1D5] PRIMARY KEY CLUSTERED ([f_id] ASC) with (pad_index = off, statistics_norecompute = off, Ignore_dup_key = OFF, allow_row_locks = on, allow_page_locks = on) on [PRIMARY]) on [Primary]go
SELECT * FROM Chexin
Career change (all data rows after August)
SELECT * from(SELECT Yuefen,8 asYue"8" asb from Chexinunion allselect Yuefen,9 asYue"9" asb from Chexinunion allselect Yuefen,Ten asYue"Ten" asb from Chexinunion allselect Yuefen, One asYue" One" asb from Chexinunion allselect Yuefen, A asYue" A" asb from Chexin) Chexinwhereyuefen>=201608
Query total data for August, after all months (including August)
Select 'a'D'SDA'C,yuefen,name,gender, (SELECT SUM (b) from(SELECT Yuefen,201608 asYue"8" asb from Chexinunion allselect Yuefen,201609 asYue"9" asb from Chexinunion allselect Yuefen,201610 asYue"Ten" asb from Chexinunion allselect Yuefen,201611 asYue" One" asb from Chexinunion allselect Yuefen,201612 asYue" A" asb from Chexin) Chexinwhereyue>=201608and yuefen>=201608) Total fromChexinwhereYuefen >=201608
Total for each month after August
SELECT Yue,sum (b) Total from(SELECT Yuefen,201608 asYue"8" asb from Chexinunion allselect Yuefen,201609 asYue"9" asb from Chexinunion allselect Yuefen,201610 asYue"Ten" asb from Chexinunion allselect Yuefen,201611 asYue" One" asb from Chexinunion allselect Yuefen,201612 asYue" A" asb from Chexin) Chexinwhereyue>=201608Group BY Yue
SQL Column Career