Re: Problem query

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <sthomas(at)peak6(dot)com>
Cc: "CS DBA" <cs_dba(at)consistentstate(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Problem query
Date: 2011-06-02 15:41:45
Message-ID: 4DE768E9020000250003E002@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Shaun Thomas <sthomas(at)peak6(dot)com> wrote:

> You're counting the number of maximum values in your table for
> tds_cx_ind and cxs_ind_2, but there will always be at least one
> for every combination.

Good point.

> What you really want is this:
>
> SELECT count(1) FROM (
> SELECT DISTINCT tds_cx_ind, cxs_ind_2
> FROM max_xtrv_st_t
> );

Or maybe:

SELECT count(DISTINCT (tds_cx_ind, cxs_ind_2)) FROM max_xtrv_st_t;

-Kevin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Kevin Grittner 2011-06-02 16:15:50 Re: Problem query
Previous Message Shaun Thomas 2011-06-02 15:34:06 Re: Problem query