SQL Column Career

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.