What is the difference between CHECKSUM_AGG() and CHECKSUM() ?
CHECKSUM
calculates a hash for one or more values in a single row and returns an integer.CHECKSUM_AGG
is an aggregate function that takes a single integer value from multiple rows and calculates an aggregated checksum for each group.They can be used together to checksum multiple columns in a group:
SELECT category, CHECKSUM_AGG(CHECKSUM(*)) AS checksum_for_category
FROM yourtable
GROUP BY category
CHECKSUM_AGG will perform a checksum across all the values that are being aggregated, coming up with a value. It's typically used to see if a collection of values (in the group) has generally changed.
CHECKSUM is intended to build a hash index based on an expression or column list. One example of using a CHECKSUM is to store the unique value for the entire row in a column for later comparison.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With