Deepthi Goguri looks at the APPROX_COUNT_DISTINCT() function in SQL Server 2019:
In the previous post, we learned about Scalar UDF Inliningfeature. In this post, let’s focus on the Approximate QP with Approx_Count_Distinct feature introduced as a part of SQL Server 2019 Intelligent Query Processing features. This feature is useful to get the approximate count of distinct values just like the Count distinct function to get the distinct number of records but this new feature will take less amount of CPU and memory to process the query.
Click through for more info. The algorithm itself is also pretty interesting.