1 comment

  • Avatar
    Brooks Duggan

    Hey Ben,

    I know this post is old, but a good way of accomplishing COUNT DISTINCT with is through the below syntax in the SQL Transform:

    Let's say you have the below table called purchases_tb...



    The below PostgreSQL will get your distinct count of salesCategory...

    SELECT COUNT(DISTINCT salesCategory) FROM purchases_tb;

    This should return the result:



    This is a very simple version of this data - if you are wanting to do this for a metric, I would suggest utilizing a version of the code below:

    SELECT "datePurchased", COUNT(DISTINCT salesCategory) FROM purchases_tb GROUP BY "DatePurchased";

    This would allow for you to create a metric that shows the distinct count of purchases by day.

    Comment actions Permalink

Please sign in to leave a comment.