5.3.6 Specifying Query Conditions
As you select columns within an object, you can specify conditions on the Conditions tab.
Conditions enable you to filter and identify the data you want to work with. You can use these attributes to modify the column alias, apply column conditions, sort columns, or apply functions.
To specify query conditions:
- On the Workspace home page, click SQL Workshop and then Query Builder.
Query Builder appears.
- Select an object from the Object Selection pane.
The selected object appears in the Design Pane.
- Select the columns to be included in your query by clicking the box to the left of the column name.
When you select a column, you are indicating you want to include it in your query. As you select each column, it appears as a separate row in the Conditions view. Use the Up and Down Arrows to control the order that the columns to be displayed in the resulting query. Available tabs include:
- Column - Displays the column name.
- Alias - Specify an optional column alias. An alias is an alternative column name. Aliases make a column name more descriptive, shorten the column name, or prevent possible ambiguous references.
- Object - Specifies table or view name.
- Condition - Specify a condition for the
column. The condition you enter modifies the query's
WHEREclause. When specifying a column condition, you must include the appropriate operator and operand. Consider the following example:>=10 ='VA' IN (SELECT dept_no FROM dept) BETWEEN SYSDATE AND SYSDATE + 15 - Sort - Type Select a sort type. Options
include: Ascending (
Asc) and Descending (Desc). - Sort Order - Enter a number (1, 2, 3, and so on) to specify the order in which selected columns should display.
- Show - Select this check box to include the
column in your query results. It is not necessary to select Show to
add a column to the query for filtering only. For example, suppose
you want to create following query:
SELECT ename FROM emp WHERE deptno = 10To create this query in Query Builder:
-
From the Object list, select emp.
-
In the Design Pane, select
enameanddeptno. -
For the deptno column, in Condition enter
=10and deselect the Show check box.
-
- Function - Select an argument function.
Available functions are dependent on the column type and include:
-
NUMBER columns -
COUNT,COUNTDISTINCT,AVG,MAX,MIN,SUM -
VARCHAR2, CHAR columns -
COUNT,COUNTDISTINCT,INITCAP,LENGTH,LOWER,LTRIM,RTRIM,TRIM,UPPER -
DATE, TIMESTAMP columns -
COUNT,COUNTDISTINCT,TO_CHARYEAR,TO_CHARQUARTER,TO_CHARMONTH,TO_CHARDAY,TO_CHARDAY OF YEAR,TO_CHARWEEK
-
- Group By - Specify columns to be used for grouping when an aggregate function is used. Only applicable for columns included in output.
- Delete - Deselect the column, excluding it from the query.
As you select columns and define conditions, Query Builder writes the SQL for you.
- To view the underlying SQL, click the SQL tab.
See Also:
Parent topic: Using Query Builder