In SQL Server the STDEV()
function returns the statistical standard deviation of all values in a specified expression.
So we can use this function to get the standard deviation of all values in a column.
Continue readingIn SQL Server the STDEV()
function returns the statistical standard deviation of all values in a specified expression.
So we can use this function to get the standard deviation of all values in a column.
Continue readingSQL Server has a GROUPING_ID()
function that returns the level of grouping based on its arguments.
We pass one or more column expressions to the function, and it computes the level of grouping. The column expressions must match the ones provided by the GROUP BY
clause.
In SQL Server, the GROUPING()
function is used to distinguish the null values that are returned by ROLLUP
, CUBE
, or GROUPING SETS
from standard null values.
Basically it tells us whether a specified column expression in a GROUP BY
list is aggregated or not.
The GROUPING()
function returns either 1
or 0
(1
indicates that the column expression is aggregated and 0
indicates that it’s not).
SQL Server has a CHECKSUM_AGG()
function that allows us to get the checksum of the values in a group. This can be useful for detecting changes in the values in a column.
In SQL Server, the APPROX_PERCENTILE_DISC()
function calculates and returns an approximate percentile based on a discrete distribution of the column values.
We pass the desired percentile to the function when we call it.
Continue readingIn SQL Server, the APPROX_PERCENTILE_CONT()
function calculates and returns an approximate percentile based on a continuous distribution of the column value. This is an interpolated value from the set of values in a group based on percentile value and sort specification.
Like most other RDBMSs, SQL Server has an AVG()
function that returns the average of the values in a group.
Below are examples that demonstrate how the AVG()
function works in SQL Server.
In SQL Server, the GREATEST()
function returns the maximum value from a list of one or more expressions.
The GREATEST()
function was introduced in SQL Server 2022 (along with the LEAST()
function).
If you’re getting an error that reads “ERROR: argument of ntile must be greater than zero” in PostgreSQL, it’s probably because you’re calling the ntile()
function with a non-positive integer.
This error occurs when we pass a non-positive integer to the ntile()
function.
To fix this issue, be sure to pass a positive integer to the function.
Continue readingSQL Server 2022 introduced the LEAST()
and GREATEST()
functions, which allow us to get the minimum or maximum value from a list of expressions.
The LEAST()
function returns the minimum value from a list of one or more expressions.