Skip to content

Feature (low priority): support COUNT(DISTINCT col) aggregate #4

Description

@david-anderson-parsolvo

Summary

Low-priority ergonomics request: support COUNT(DISTINCT col) as an aggregate.

Motivation

Today, getting a distinct-value count takes a query plus an external line count:

xql csv apps.csv --exec "SELECT DISTINCT application_name WHERE application_name IS NOT NULL" --mode=csv --no-output-header | grep -c .

COUNT(DISTINCT col) would collapse that to one self-contained query:

xql csv apps.csv --exec "SELECT COUNT(DISTINCT application_name) WHERE application_name IS NOT NULL"

It would also sidestep an easy off-by-one: an unfiltered SELECT DISTINCT counts the NULL/blank group as one distinct value, so the piped count reads one higher than the number of real values unless you remember to add IS NOT NULL.

Priority / scope

Low priority, pure convenience — the SELECT DISTINCT + count workaround works fine. Just COUNT(DISTINCT col); no need for multi-column COUNT(DISTINCT a, b) unless it's trivial to include.

Version / environment

  • xql 1.5.0
  • Linux (x86_64), bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions