How Do I...
Suppose you have the following SQL SELECT statement:
SELECT EMPLOYEE.JOBCODE, WAGES.GROSSPAY, EMPLOYEE.NAME
FROM EMPLOYEE, WAGES
WHERE (EMPLOYEE.NUMBER = WAGES.EMPNUMBER) AND (EMPLOYEE.STATE = 'NC')
ORDER BY EMPLOYEE.JOBCODE ASC, WAGES.GROSSPAY DESC
To specify the statement:
- In the Query name field, type a name for the SELECT
statement.
- In the Description field, type a description for the SELECT
statement.
- In the Tables/views list, select EMPLOYEE and
WAGES.
- In the Columns list, select EMPLOYEE.JOBCODE,
EMPLOYEE.NAME, and WAGES.GROSSPAY.
- In the Column sequence list, select
EMPLOYEE.NAME.
- From the Column sequence pop-up menu, select Move
after > WAGES.GROSSPAY.
- From the Clause menu, select WHERE.
Next, in the displayed WHERE Details window:
- In the Left operand field, select
EMPLOYEE.NUMBER.
- In the Operator field, select =.
- In the Right operand field, select
WAGES.EMPNUMBER.
- Select Add to operand lists.
- In the Left operand field, select
EMPLOYEE.STATE.
- In the Operator field, select =.
- In the Right operand field, type
NC
- From the Unary operator menu, select Right operand
String constant 'x'.
- Select Add to operand lists.
- In the Left operand field, select (EMPLOYEE.NUMBER
= WAGES.EMPNUMBER).
- In the Operator field, select AND.
- In the Right operand field, select (EMPLOYEE.STATE
= 'NC').
- Select Apply.
Finally, complete the statement:
- From the Clause menu, select ORDER BY.
- In the ORDER BY Details window, do the following:
- In the Columns list, select EMPLOYEE.JOBCODE
and WAGES.GROSSPAY.
- In the ORDER BY sequence list, select
WAGES.GROSSPAY.
- From the ORDER BY sequence pop-up menu, select Descending
(DESC).
- Select Apply.
Suppose you have the following SQL SELECT statement:
SELECT EMPLOYEE.JOBCODE, COUNT(*)
FROM EMPLOYEE
GROUP BY EMPLOYEE.JOBCODE
HAVING MAX(EMPLOYEE.AGE) > 40
To specify the statement:
- In the Query name field, type a name for the SELECT
statement.
- In the Description field, type a description for the SELECT
statement.
- In the Tables/views list, select EMPLOYEE.
- In the Columns list, select
EMPLOYEE.JOBCODE.
- From the Computed columns pop-up menu, select
Create.
- In the Computed Column Details window, select COUNT(*) from the
Unary operator menu; then select Apply.
- In the Computed columns list, select
COUNT(*).
- From the Clause menu, select GROUP BY.
- In the GROUP BY Details window, select EMPLOYEE.JOBCODE
in the Columns list, and select Apply.
- From the Clause menu, select HAVING.
Finally, in the HAVING Details window, do the following:
- In the Left operand field, select
EMPLOYEE.AGE.
- From the Unary operator menu, select Left operand
> MAX(x).
- In the Operator field, select >.
- In the Right operand field, type
40
- Select Apply.
[ Top of Page | Previous Page | Next Page | Table of Contents ]