2. Orders are structured sequences.
The cube inherits the concept of a data table in a relational database and is called a sequence table. Consistent with the concept of relational databases, each sequence table also has its own data structure, which consists of several fields. The members of the sequence table are called records.
2.1 structured Two-Dimensional Data Objects
A Sequence member can be of any data type, such as a common type, another sequence, or record. The members of the sequence table must be records, and each record has the same structure. For example, the following data objects are sequential tables:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4C/DC/wKiom1RG_1bTSCvaAAE5Aycln0w267.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_1.jpg "alt =" wkiom1rg_1btscvaaaa 5aycln0w267.jpg "/>
Because it is a structured two-dimensional data object, the Order table is usually generated from SQL, text files, binary files, Excel files, and can also be created from a blank order table. The following A1, B1, and c1 are sequential tables:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/4C/DD/wKioL1RG_6OTgVbQAABjkGseyxk165.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_2.jpg "alt =" wkiol1rg_6otgvbqaabjkgseyxk165.jpg "/
A1 generates a sequence table from a text file and the result obtained is the preceding sequence table. B1 uses SQL to generate a sequence table. C1 specifies the field name to create an empty sequence table. The data in B1 and C1 is as follows:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/4C/DC/wKiom1RG_1fQYufCAACtxbN84HU348.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_3.jpg "alt =" wkiom1rg_1fqyufcaactxbn84hu348.jpg "/>
Ordered tables support a large number of structured data algorithms, including query, sorting, sum, average, and merge duplicate records. For example:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4C/DD/wKioL1RG_6SxSshiAACMGyYUG7Y458.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_4.jpg "alt =" wkiol1rg_6sxsshiaacmgyyug7y458.jpg "/>
In A2, the value of amount is greater than or equal to 20000, and date is the record of January 1, May:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4C/DC/wKiom1RG_1miz88aAAFHr9t8Mss304.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_5.jpg "alt =" wkiom1rg_1miz88aaafhr9t8mss304.jpg "/>
A3 records are sorted in ascending order by salesid fields, and in descending order by date when salesid is the same:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4C/DD/wKioL1RG_6aRH635AAExr39EHs0989.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_6.jpg "alt =" wkiol1rg_6arh635aaexr39ehs0989.jpg "/>
A4 sum the amount of data in each group by salesid and month, and calculate the order count of this group:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4C/DC/wKiom1RG_1rDDLM-AACLYFjrtyc053.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_7.jpg "alt =" wKiom1RG_1rDDLM-AACLYFjrtyc053.jpg "/>
A 2.2-order table is a special sequence.
The sequence table is still a sequence. The collection, ordering, and related functions of the sequence are applicable to the sequence table. For generics, because the sequence table members must be records of the same structure, the sequence type is no longer supported, but the recorded field value can be generic data, it can be said that it is another generic meaning. With these features, orders tables are better at processing complex computing problems than traditional programming languages.
For example, an orderly solution: the monthly sales volume increases by a few percent over the previous month. The sequence table algorithm is as follows:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/4C/DD/wKioL1RG_6eBoY1NAAB89hF6f8w717.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_8.jpg "alt =" wkiol1rg_6eboy1naab89hf6f8w717.jpg "/
A2 first calculates the total monthly sales:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/4C/DC/wKiom1RG_1yzD20KAACJYcSmopg955.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_9.jpg "alt =" wkiom1rg_1yzd20kaacjycsmopg955.jpg "/>
The final result calculated in A3 is as follows:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4C/DD/wKioL1RG_6mSU-tCAACeljaXf_0782.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_10.jpg "alt =" wKioL1RG_6mSU-tCAACeljaXf_0782.jpg "/>
Integration: Assume that orders with more than 1000 orders are called large orders, and orders with a unit price greater than 10000 are called important contracts. Please find out: ① orders are both large orders and important orders; ② and other orders:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4C/DC/wKiom1RG_13D0AHgAAB9juEb58c031.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_11.jpg "alt =" wkiom1rg_13d0ahgaab9jueb58c031.jpg "/>
Select a large contract in B2. then select an important contract in B3. The intersection of two types of contracts is calculated in A4, which is the answer to Question ①:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4C/DD/wKioL1RG_6vAISV-AAE6u5lkM-c018.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_12.jpg "alt =" wKioL1RG_6vAISV-AAE6u5lkM-c018.jpg "/>
In B4, use the result of all orders and question ① as the difference set to obtain the answer to Question ②:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4C/DC/wKiom1RG_2Gg41iWAAE_EWpItFc310.jpg "style =" float: none; "Title =" esproc_programm_seq&tseq2_13.jpg "alt =" wkiom1rg_2gg41iwaae_ewpitfc310.jpg "/>
Note that A1 in the above Code is a sequence table, while B2, B3, A4, and B4 are all derived from the sequence table. The differences and connections between the two are described below.
Sequence and sequence table of the Set calculator Program (2)