130 likes | 267 Views
TEAM14 General format of SELECT statement. head :林志平 Members :陈海洪 朱小明 龚云冰 曹兴 孙源斌. 3.3.6 General format of SELECT statement. SELECT [ALL|DISTINCT]
E N D
TEAM14General format of SELECT statement head :林志平 Members :陈海洪 朱小明 龚云冰 曹兴 孙源斌
3.3.6 General format of SELECT statement SELECT [ALL|DISTINCT] < Out goals expression > [alias ] [ ,< Out goals expression > [alias ]] … FROM <Table or view name> [alias] [ ,< Table or view name > [alias]] … [WHERE <conditional expression >] [GROUP BY <column name 1>[HAVING< conditional expression >] ]... [HAVING < conditional expression >]] [ORDER BY < column name 2> [ASC|DESC] ];
ALL | DIATINCT: ALL inquiries to satisfy all conditions-byte; DIATINCT said that the elimination of duplicate tuple; • FROM: clause to be designated for the query data sources, that is, table or view name; • WHERE: clause for the query that data to meet the conditions of access; • GROUP BY: clause for the results of the group; • ORDER BY: clause for the sort of results, ASC, said ascending, DESC descending said.
The whole meaning of the SELECT statement is based on the WHERE clause of the conditions of expression, from the FROM clause specified in the basic view or to find out the conditions to meet the meta-group, and then SELECT clause in the expression of the target set out to elect yuan The group formed a list of property value, results in the table can be grouped and sorted.
Out goals expression • 1.Out goals expression format (1) * (2) <table name >. * (3) COUNT([DISTINCT|ALL]*) (4) [<table name >.]<Attribute listed expression>[,[< table name >.]< Attribute listed expression >] … One, <Attribute names expression>: By the Attribute column , in the role of the attributes set out the function of the constant and arbitrary arithmetic operations (+,-,*,/) composition of the formula for computing.
2.Set function format page:98 COUNT SUM AVG ([DISTINCT|ALL] < column name>) MAX MIN COUNT ([DISTINCT|ALL] *)
SQL in the WHERE and HAVING difference??? • HAVING clause enables us to filter into the group after the data, WHERE clause in the aggregate prior to screening records. That is to say in the role of the GROUP BY and HAVING clause before the clause; and HAVING clause in the aggregate after the group recorded Screen.
SELECT region, SUM(population), SUM(area)FROM bbcGROUP BY regionHAVING SUM(population)>1000000
3.Conditional expression format:the conditions where clause expression (1) < Attribute column name > <Attribute column name >θ <Constant > [ANY|ALL] (SELECT statement)
条件表达式格式 (3) (<value 1>[,<value 2> ] …) < Attribute column name> [NOT] IN (SELECT statement)
条件表达式格式 (4) < Attribute column name > [NOT] LIKE <Match string > (5) < Attribute column name > IS [NOT] NULL (6) [NOT] EXISTS (SELECT statement)
条件表达式格式 (7) AND <Conditional expression > <Conditional expression > or AND <Conditional expression > … OR
That’s all what I say,thanks! Pursue Thank you very much