@@ -703,6 +703,9 @@ SELECT payment_type, corr(price, quantity) FROM transactions GROUP BY payment_ty
703703- ` count() ` or ` count(*) ` - counts the number of rows irrespective of underlying
704704 data.
705705- ` count(column_name) ` - counts the number of non-NULL values in a given column.
706+ - ` count(distinct column_name) ` - counts the number of distinct non-NULL values
707+ in a given column. This is identical to
708+ [ ` count_distinct(column_name) ` ] ( #count_distinct ) .
706709
707710#### Parameters
708711
@@ -774,9 +777,22 @@ SELECT payment_type, count(amount) FROM transactions;
774777| card | 67 |
775778| NULL | 4 |
776779
780+ Count distinct values using standard SQL syntax (identical to ` count_distinct ` ):
781+
782+ ``` questdb-sql
783+ SELECT payment_type, count(distinct counterparty) FROM transactions;
784+ ```
785+
786+ | payment_type | count |
787+ | :----------- | :---- |
788+ | cash | 3 |
789+ | card | 23 |
790+ | NULL | 5 |
791+
777792::: note
778793
779794` NULL ` values are aggregated with ` count() ` , but not with ` count(column_name) `
795+ or ` count(distinct column_name) ` .
780796
781797:::
782798
@@ -790,6 +806,13 @@ SELECT payment_type, count(amount) FROM transactions;
790806` count_distinct(column_name) ` - counts distinct non-` NULL ` values in ` varchar ` ,
791807` symbol ` , ` long256 ` , ` UUID ` , ` IPv4 ` , ` long ` , ` int ` or ` string ` columns.
792808
809+ ::: tip
810+
811+ ` count_distinct ` is available for backwards compatibility. We recommend using
812+ the standard SQL syntax [ ` count(distinct column_name) ` ] ( #count ) instead.
813+
814+ :::
815+
793816#### Return value
794817
795818Return value type is ` long ` .
0 commit comments