Databases Reference
In-Depth Information
As you add and join tables and select columns to operate on, the region at the bottom of the screen begins to
change. This region is subdivided into several tabs:
The
Conditions tab
shows one row for each column selected in the area above and allows
you to further define its attributes. (More on this feature in just a moment.)
The
SQL tab
displays the SQL statement as the wizard builds it. Although it's not directly
editable, you can easily highlight the statement and cut it to the clipboard from here.
The
Results tab
shows the results of running the SQL statement and allows you to download
the resulting data in CSV format.
The
Saved SQL tab
allows you to save, recall, and manage statements that have been built
with the Query Builder. There are also filters that let you search and limit which saved
queries display.
All but the Conditions tab are self explanatory, so lets go over this one in a little more detail. Figure
2-20
shows an
example three-table join with five columns selected to operate on.
Figure 2-20.
An example three-table join
In this example, the following modifications have been applied to the query:
ORDER_TOTAL
column to
SUM_OF_ORDERS
•
Changed the alias of the
ORDER_TOTAL
is less than 500
•
Limited the result set to only those records where
CUST_LAST_NAME
,
CUST_FIRST_NAME
ascending
•
Sorted the records returned by
SUM
function on the
ORDER_TOTAL
column
•
Performed a
USER_NAME
,
CUSTOMER_ID
,
CUST_FIRST_NAME
,
CUST_LAST_NAME
•
Grouped the query by
Based on the column selections and the restrictions and changes introduced in the Conditions tab, the SQL
statement (as it appears in the SQL tab) looks like this:
select "DEMO_USERS"."USER_NAME" as "USER_NAME",
"DEMO_CUSTOMERS_2"."CUSTOMER_ID" as "CUSTOMER_ID",