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.
If you’ve ever used the UNION
clause in a SQL query, chances are you used UNION ALL
or just UNION
by itself. But some RDBMSs also accept a UNION DISTINCT
option.
The UNION DISTINCT
option is basically the equivalent of UNION
by itself. That is, it removes redundant duplicate rows.
When using the GROUP BY
clause in SQL Server, we can use the GROUPING SETS()
option to combine multiple GROUP BY
clauses into one GROUP BY
clause. When we do this, the results are the equivalent of doing a UNION ALL
of the specified groups.
SQL Server provides GROUP BY CUBE()
functionality that we can use in our SQL queries, which creates groups for all possible combinations of columns.
It’s similar to the GROUP BY ROLLUP()
functionality, except that it can provide us with more information, due to the fact that it groups all possible combinations.
When we use the GROUP BY
clause in SQL Server, we have several options for specifying how the GROUP BY
operation is applied. One such option is the ROLLUP
modifier. We can use this modifier to create subtotals and grand totals.
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.