Sorting, de-weight, grouping, job

Source: Internet
Author: User

All: the meaning of all
In: Represents a Conditional "in ()" within a certain range of parameters, which is a write parameter, equivalent to multiple or
Select *from file name where table name in ()
Not: act as a modifier, reverse, write in front
Select *from file name where table name not in ()
Between and means within a range, equivalent to >= <=
Select *from filename where ids>500 and ids<505
Select *from file name where IDs between and 505
Fuzzy query, the industry with the country two words
Select *from filename where name like '% country% '
Select *from filename where name like ' Country '
Select *from filename where name like '% Agency '
Select *from file name where name not a like '% country% '


Select *from file name where IDs > All
(
Select IDs from file name where IDs >1190 and IDs <1995

)
Any: greater than small, less than large (greater than the one inside)
Find a column to use as a parameter


How to sort
--select *from file name order by IDs table column
ASC: The Meaning of ascending
Desc: From the big to the small row
To sort two columns
Select *from file name ORDER by Parent,ids
Parent,ids: for column names

Grouping: Dividing a column into a group of the same
Select column name from file name Group By column name
Select code from filename where parent= ' m '


Go heavy
Select distinct parent from category
Number of previous data
Select Top 5 *from Category
Select Top 5 *from category order by IDs
Select Top 5 *from dategory where ids>900 and ids<950 order by IDs


--Student Information Form
--School number, name, class, gender, teacher, date of birth, height
Add 20 virtual data
Find out more than 170 of the height of male students
Inquire about the surname Wang's classmates
Find a few classes in total
Query the female classmate height in 168,170,172 fold three number of information
CREATE TABLE Xueshengxinxibiao
(
Xuehao int,
Name varchar (50),
Class varchar (50),
Xingbie varchar (50),
Jiaoshi varchar (50),
Chushengriqi varchar (50),
Shengao varchar (50)
)
INSERT into Xueshengxinxibiao values (1, ' Qiao ', ' First grade class ', ' Male ', ' tianlong ', ' 1988-03-14 ', ' 181cm ')
INSERT into Xueshengxinxibiao values (2, ' Zhu ', ' First grade class ', ' female ', ' tianlong ', ' 1988-04-05 ', ' 168cm ')
INSERT into Xueshengxinxibiao values (3, ' Duan Yu ', ' First grade class ', ' Male ', ' tianlong ', ' 1988-12-09 ', ' 178cm ')
INSERT into Xueshengxinxibiao values (4, ' Wang ', ' First grade class ', ' female ', ' tianlong ', ' 1988-05-06 ', ' 173cm ')
INSERT into Xueshengxinxibiao values (5, ' Virtual bamboo ', ' First grade class ', ' Male ', ' tianlong ', ' 1988-06-04 ', ' 178cm ')
INSERT into Xueshengxinxibiao values (6, ' dream ', ' First grade class ', ' female ', ' tianlong ', ' 1988-07-19 ', ' 172cm ')
INSERT into Xueshengxinxibiao values (7, ' Murong Forte ', ' First grade class ', ' Male ', ' tianlong ', ' 1988-12-18 ', ' 175cm ')
INSERT into Xueshengxinxibiao values (8, ' Sprite ', ' First grade class ', ' female ', ' tianlong ', ' 1988-09-01 ', ' 165cm ')
INSERT into Xueshengxinxibiao values (9, ' Mrs. Wang ', ' First grade class ', ' female ', ' tianlong ', ' 1988-08-08 ', ' 165cm ')
INSERT into Xueshengxinxibiao values (10, ' angry ', ' first grade class ', ' female ', ' tianlong ', ' 1988-06-01 ', ' 160cm ')
INSERT into Xueshengxinxibiao values (11, ' Duan Zheng Chun ', ' First grade class ', ' Male ', ' tianlong ', ' 1988-03-04 ', ' 176cm ')
INSERT into Xueshengxinxibiao values (12, ' Yang over ', ' first grade Class two ', ' Male ', ' Condor ', ' 1988-10-01 ', ' 180cm ')
INSERT into Xueshengxinxibiao values (13, ' time moved ', ' Grade three ', ' Male ', ' margin ', ' 1988-09-25 ', ' 170cm ')
INSERT into Xueshengxinxibiao values (14, ' Song Jiang ', ' Grade three ', ' Male ', ' margin ', ' 1988-05-23 ', ' 173cm ')
INSERT into Xueshengxinxibiao values (15, ' Lin ', ' first grade class three ', ' Male ', ' margin ', ' 1988-11-11 ', ' 183cm ')
INSERT into Xueshengxinxibiao values (16, ' Erniang ', ' First grade class three ', ' female ', ' margin ', ' 1988-02-18 ', ' 174cm ')
INSERT into Xueshengxinxibiao values (17, ' Little Dragon Girl ', ' first grade Class two ', ' Female ', ' Condor ', ' 1988-06-19 ', ' 168cm ')
INSERT into Xueshengxinxibiao values (18, ' Rong Wang ', ' first grade Class two ', ' Female ', ' Condor ', ' 1988-08-23 ', ' 165cm ')
INSERT into Xueshengxinxibiao values (19, ' Guo Jing ', ' First grade Class two ', ' Male ', ' Condor ', ' 1988-08-13 ', ' 175cm ')
INSERT into Xueshengxinxibiao values (20, ' hung seven Male ', ' first grade Class two ', ' Male ', ' Condor ', ' 1988-08-29 ', ' 170cm ')
Select *from Xueshengxinxibiao
Select *from Xueshengxinxibiao where xingbie= ' man ' and Shengao > ' 170cm '
Select *from Xueshengxinxibiao where name like '% King '
Select class from Xueshengxinxibiao Group by class
Select *from Xueshengxinxibiao where xingbie= ' female ' and (Shengao = ' 168cm ' or shengao= ' 170cm ' or shengao= ' 172cm ')
--the height of the male classmate is higher than that of all the female classmates.
Select Top 3 *from xueshengxinxibiao where Shengao not in (select Top 5 Shengao from Xueshengxinxibiao order by Shengao de Sc,xuehao desc) Order BY Shengao Desc

--the height of the male classmate is higher than that of all the female classmates.
Select *from Xueshengxinxibiao where xingbie= ' man ' and Shengao>all (select Shengao from Xueshengxinxibiao where xingbie= ' Female ')

Sorting, de-weight, grouping, job

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.