7. Working with Numbers
Computing an Average
We want to compute the average value in a column.
Computing the average of all employee salaries
Compute the average salary for each department
Finding the Min/Max Value in a Column
We want to find the highest and lowest values in a given column.
Lowest and highest salaries for all employees
Lowest and highest salaries for each department
Summing the Values in a Column
We want to compute the sum of all values in a column.
Sum for all employees
Sum for each department
Counting Rows in a Table
We want to count the number of rows in a table, or want to count the number of values in a column.
Counting rows for the whole table
Counting rows for each department
Counting Values in a Column
We want to count the number of non-NULL values in a column
Generating a Running Total
We want to calculate a running total or cumulative of values in a column
Generating a Running Product
We want to compute a running product on a numeric column
Smoothing a Series of Values
We have a series of values that appear over time, such as monthly sales figures. We want to implement a simple smoother, such as weighted running average.
A moving average can be calculated by summing the current value and the preceding n-1 values and dividing by n.
Calculating a Mode
We want to find the mode.
Calculating a Median
We want to calculate the median.
Determining the Percentage of a Total
We want to determine the percentage that values in a specific column represent against a total. For example, we want to determine what percentage of all salaries are the salaries in DEPTNO 10 (the percentage that DEPTNO 10 salaries contribute to the total)
Aggregating Nullable Columns
We want to perform an aggregation on a column, but the column is nullable.
Computing Averages Without High and Low Values
We want to compute an average, but excluding the highest and lowest values
Converting Alphanumeric Strings into Numbers
We have alphanumeric data and would like to return numbers only. You want to return the number 123321 from the string “pjenil123g321.”
Changing Values in a Running Total
We want to modify the values in a running total depending on the values in another column.
Last updated
Was this helpful?