Sol function Primary query, de-weight, group, sort

Source: Internet
Author: User

CREATE TABLE Student1 (codeintprimary key,name varchar (Ten) unique,birthday datetime,sex varchar (5), Heightdecimal( -,0))Select* fromStudentinsert into student values (001,'to Aleees','male','1989/03/06',186)Select* fromstudentupdate StudentSetbirthday='1987/12/21', sex='male'whereName ='Dong Sheng'--Conditional query: Where filter:> < >= <=! =and orSelect* fromCarwhereoil<8and powers> the--Fuzzy query likeSelect* fromCarwhereName like'BMW 3 Series%'and price< $--SortSelect* fromcar Order by oil ASCSelect* fromcar order by oil descSelect* fromCarwhereName like'% BMW%'order by oil desc--Go heavySelectDistinct brand fromCar--GroupingSelectBrand fromCar GROUP BY BrandSelect*From car--aggregate function: AVG () Max () min () sum ()SelectAVG (Price) fromCarSelectAVG (Price) fromCarwhereName like'% BMW%'SelectMax (price) most expensive, min (price) lowest fromCarwhereName like'% BMW%'SelectCOUNT (*) fromCarwhereName like'% BMW%'SelectBrand,count (*), AVG (Price) fromCar GROUP BY Brand--Date-time functionsSelectSysdatetime ()--time of the systemSelectGETDATE ()--timestamp of database serviceSelectYear ('1999-09-23')SelectMONTH ('1999-09-23')SelectISDATE ('2015-06-30')SelectDATEADD (Week,5,)SelectDatename (DayOfYear,'2015-06-26')SelectDATEpart (Weekday,'2015-06-26')--String FunctionsSelectUpper (pic) from carSelectLTRIM ('123213')Select '12313'SelectLeft ('abcdef',3)SelectLEN ('AFDFASFD')SelectLOWER ('ACDFDD')SelectREPLACE ('ac123123123ac123123123','AC','haha')SelectREPLICATE ('ABC',Ten)SelectREVERSE ('ABC')SelectRight ('123123ADF',3)SelectSTR (1.567,3,2)SelectSUBSTRING ('ABCDEFG',2,3)--math function: ABS ceiling floor square sqrt round piSelectCode,name,ceiling (Price) fromCarSelect* fromCarwhereName like'% Audi%'and square (floor) >=2500--Conversion FunctionsSelectCode,name,'Fuel Consumption'+cast (oil asvarchar -)) fromCarSelectCode,name,'Fuel Consumption'+convert (varchar ( -), oil) fromCar

Sol function Primary query, de-weight, group, sort

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.