title: With Postgres How to Group By range type
body: <p>What is the best way to group by exclusive range type.  Consider the following.</p>
  
  <pre><code>CREATE EXTENSION IF NOT EXISTS btree_gist;
  
  create table if not exists ranges (
      "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
      "name" character varying NOT NULL,
      "range" numrange NOT NULL,
      EXCLUDE USING gist (range WITH &amp;&amp;)
  );
  
  create table if not exists customers (
      "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
      "name" character varying NOT NULL,
      "score" integer NOT NULL
  )
  
  insert into ranges (name, range) VALUES ('awesome', '[75,)'::numrange);
  insert into ranges (name, range) VALUES ('good', '[50,75)'::numrange);
  insert into ranges (name, range) VALUES ('ok', '[25,50)'::numrange);
  insert into ranges (name, range) VALUES ('bad', '[,25)'::numrange);
  
  insert into customers (name, score) VALUES ('A', 10);
  insert into customers (name, score) VALUES ('B', 10);
  insert into customers (name, score) VALUES ('C', 80);
  </code></pre>
  
  <p>I want a query that will return the following ...</p>
  
  <pre><code>  | range name | count of customers in range |
    | 'awesome'  | 1                           |
    | 'bad'      | 2                           |
  </code></pre>
  
  <p>I am not sure how to achieve this.  Would love some guidance</p>
  
  <p>Thanks!!</p>
  
  <p>(Note: On PG 12)</p>