Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Reference Index > Expressions

Examples of Expressions

Scroll Prev Top Next More

In the following example, the first command defines the data type of the result variable and assigns an initial value of zero. The second sets the value of vctr to the current value of vctr plus one. This is the most common method of counting occurrences in a command file.

 

SET VARIABLE vctr INTEGER = 0

SET VARIABLE vctr = (.vctr + 1)

 

In the following example, CREATE TABLE defines the computed column bonus. Netamount and bonuspct are defined first with CURRENCY and REAL data types, respectively. Bonus is then defined as a computed column, the result of multiplying netamount by bonuspct.

 

CREATE TABLE salesbonus (netamount CURRENCY, bonuspct +

REAL, bonus = (netamount * bonuspct) CURRENCY)

 

In the following example, the command uses select functions to calculate the total sales amount and total cost. The cost is then subtracted from the price to see the amount of profit.

 

SELECT (SUM(price)-SUM(cost)) from orders

 

See Also

 

Rules for Defining Expressions