Perform Calculations (Cambridge (CIE) IGCSE ICT)
Revision Note
Perform calculations
How do you perform calculations in a database?
In a database, you can use arithmetic operations or numeric functions to perform calculations
Calculated fields are fields that carry out a calculation based on other number fields in the database
For example, a 'products' table with a
stock
andunit_price
fieldsYou could use a calculated field named
stockvalue
to calculateunit_price
*stock
This calculation multiplies the price of each item by its quantity to find the total value of the stock
Calculated controls are objects you place on forms or reports to display the result of an expression
For example, a form in a sales database where you input the
QuantitySold
andUnitPrice
A calculated control could be used to display the
TotalSale
TotalSale = QuantitySold * UnitPrice
This displays the total sale on the form without storing it in the database
Using formulae and functions to perform calculations
Databases allow you to use formulae and functions to perform calculations at run time
This can include basic arithmetic operations: addition, subtraction, multiplication, and division
For example, you have a discount field and you want to subtract it from the total cost, you could use a subtraction operation like this:
FinalCost = TotalCost - Discount
Aggregate functions
You can also use aggregate functions to calculate statistical information about a set of records
Some examples include:
Sum | Adds together all the numbers in a column |
|
---|---|---|
Average | Computes the average of a set of numbers in a column |
|
Maximum | Finds the highest number in a column |
|
Minimum | Finds the lowest number in a column |
|
Count | Counts the number of rows in a column |
|
Remember that the actual syntax and function names might differ slightly depending on the specific database system being used.
You've read 0 of your 5 free revision notes this week
Sign up now. It’s free!
Did this page help you?