Re: Problem query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



CS DBA <cs_dba@xxxxxxxxxxxxxxxxxxx> wrote:
 
> The app wants to run a query like this:
> 
> select count(pri_num) from max_xtrv_st_t
> where pri_num in (select max(pri_num) from max_xtrv_st_t where 1=1
>                                 group by tds_cx_ind, cxs_ind_2)
 
Why not something simpler?  There are a number of possibilities, and
I don't claim this one is necessarily best (or even error free), but
how about something like?:

select count(*) from 
  (select distinct max(pri_num)
  from max_xtrv_st_t
  group by tds_cx_ind, cxs_ind_2) x
 
-Kevin

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux