Design and implement the basic functions of the module management system define your own (38--Ultimate Stage Comprehensive query [5])

Source: Internet
Author: User

General Enquiry (5)--Select reference module
What is a benchmark module. Is your comprehensive query to which module as the main module of the query, I did not think of other words, use this to express. In a detailed sense. Is that you choose a number of modules of the field to form a query, you want to show which module of the content.

For example, in our previous sections, the modules selected are "orders" and "Order Details", with "orders" and "Order Details" as the benchmark modules respectively. Now, let's talk about the differences between the two parent-child modules as reference modules.


1, sub-module as a benchmark module: At this point all the parent module fields will be incremented.



the SQL statement for the query is:
 Select//Order detail fields _t        6050.tf_ordersdetailid as Tf_ordersdetailid, _t6050.tf_name as Tf_name, _t6050.tf_number as Tf_number,  _t6050.tf_unitprice as Tf_unitprice, _t6050.tf_subtotalprice as Tf_subtotalprice, _t6050.tf_remark as Tf_remark,//Order field _t6040.tf_date as _t6040___tf_date, _t6040.tf_finished as _t6040___tf_f    Inished, _t6040.tf_ordersid as _t6040___tf_ordersid, _t6040.tf_ordersnumber as _t6040___tf_ordersnumber, From Ordersdetail _t6050//Order Details left OUTER JOIN orders _T6040//order on _t6040.tf_ordersid = _t6050.tf_ordersid 

        2 when the parent module is used as the reference module. The sub-module records can only appear as aggregated fields. Fields that do not have an aggregation operation will be abandoned.



the resulting SQL statement is:

Select//Order information _t6040.tf_ordersid as TF_ORDERSID, _t6040.tf_ordersnumber as Tf_ordersnumber, _t60 40.tf_date as Tf_date, _t6040.tf_finished as tf_finished, _t6040.tf_remark as Tf_remark,/ /Order Detail Quantity Summary (select SUM (_t6050.tf_number) from Ordersdetail _t6050 left Oute            R join Orders _child_t6040 on _child_t6040.tf_ordersid = _T6050.TF_ORDERSID where _child_t6040.tf_ordersid = _t6040.tf_ordersid) as S__t6050___tf_number,//Amount Summary of order details (S            Elect sum (_t6050.tf_subtotalprice) from Ordersdetail _t6050 left outer JOIN Orders _child_t6040 on _child_t6040.tf_ordersid = _T6050.TF_ORDERSID where _child_ T6040.tf_ordersid = _t6040.tf_ordersid) as S__t6050___tf_subtotalprice from Orders _t6040

In the example above, only the aggregation of sums is shown. So suppose you want to increase the count, the maximum, the minimum, and how to do the average.

The previous sections describe the selection field. When you enter a condition for a field, there are 5 checkboxes below the criteria value that you use to set the field. Which aggregated fields can be generated.


Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvamzvaw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center ">


After the
run has been determined. Let's take a look at the query results:

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvamzvaw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center ">


The SQL statement, like the one above, adds count, Max, Min,avg, and so on. This interface can also add extensions later on. For example, add a link to the "Quantity" value, you can see the details at a point, and a link on the value of "maximum" to see the "Order Detail" of the maximum value, and so on.





Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Design and implement the basic functions of the module management system define your own (38--Ultimate Stage Comprehensive query [5])

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.