RDOHELP72.HLB  —  Value expr, statistical_expression, Format
  (B)0statistical-expr =

    qqqqqqqwqq> MAX qqqqqwqq> value-expr qqwqq> OF qq> rse qq>
           tqq> MIN qqqqqu                 x
           tqq> TOTAL qqqu                 x
           tqq> AVERAGE qj                 x
           mqq> COUNT qqqqqqqqqqqqqqqqqqqqqj

1  –  MAX

    --> MAX --> value-expr --> OF --> rse -->

    Find the highest paid employee in the company:

    START_TRANSACTION READ_ONLY

    FOR SAL IN CURRENT_SALARY WITH SAL.SALARY_AMOUNT =
        MAX CURR.SALARY_AMOUNT OF
            CURR IN CURRENT_SALARY
    PRINT SAL.EMPLOYEE_ID,
          SAL.LAST_NAME,
          SAL.SALARY_AMOUNT
    END_FOR

    COMMIT

2  –  MIN

    --> MIN --> value-expr --> OF --> rse -->

    Find the job title with the smallest minimum salary:

    FOR J IN JOBS WITH J.MINIMUM_SALARY =
          MIN JM.MINIMUM_SALARY OF JM IN JOBS
    PRINT J.JOB_TITLE,
          J.MINIMUM_SALARY
    END_FOR

3  –  TOTAL

    --> TOTAL --> value-expr --> OF --> rse -->

    Assign the total payroll for the company to a host language
    variable:

    &RDB&   START_TRANSACTION READ_ONLY
    &RDB&       GET TOTAL-SALARY = TOTAL CH.SALARY_AMOUNT
    &RDB&            OF CH IN CURRENT_SALARY
    &RDB&   END_GET
    &RDB&   COMMIT

4  –  AVERAGE

    --> AVERAGE --> value-expr --> OF --> rse -->

    Display the average salary of all the employees whose salaries
    exceed $50,000:

    PRINT  AVERAGE CS.SALARY_AMOUNT OF
            CS IN CURRENT_SALARY WITH
             CS.SALARY_AMOUNT GT 50000

5  –  COUNT

    --> COUNT --> OF --> rse -->

    The following COBOL code fragment finds out the number of
    employees who live in a particular state, specified by the host
    language variable STATE:

    ACCEPT STATE.
    &RDB&   GET STATE-COUNT = COUNT OF E IN EMPLOYEES
    &RDB&            WITH E.STATE = STATE
    &RDB&   END_GET
            DISPLAY "Number of employees in ", STATE, " is ",
                STATE-COUNT.
Close Help