Re: efficient count/join query - Mailing list pgsql-sql

From Gary Stainburn
Subject Re: efficient count/join query
Date
Msg-id 200302071421.14672.gary.stainburn@ringways.co.uk
Whole thread Raw
In response to Re: efficient count/join query  (Tomasz Myrta <jasiek@klaster.net>)
List pgsql-sql
On Friday 07 Feb 2003 1:26 pm, Tomasz Myrta wrote:
> Gary Stainburn wrote:
> > On Friday 07 Feb 2003 10:48 am, Tomasz Myrta wrote:
>
> <cut>
>
> > Hi Tomasz,
> >
[snip]
>
> I understood your problem well and I just thought some idea will be enough
> to continue work.
>
> Here is detailed query for your problem:
>
> create view some_view as
> select
>  coalesce(hjid,rjid) as jid,
>  coalesce(hsid,rsid) as sid,
>  coalesce(hcount,1)+count(*)-1 as hcount
> from
>  history
>  full outer join roster on (hjid=rjid and hsid=rosid)
> group by hjid,rjid,hsid,rosid;
>
> Regards,
> Tomasz Myrta

Many appologoes Tomasz.

Because your select *LOOKED* wrong to me, I didn't even try it.  Upon looking
at it again I can see what you're doing.  When I tried, it complained about
the counts and grouping, so I moved the count(*) to a sub-select and changed
the coalesce and it's working.

Thanks,

Gary

>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000



pgsql-sql by date:

Previous
From: "jose antonio leo"
Date:
Subject: prosgrees + java + trasnacciones
Next
From: Tomasz Myrta
Date:
Subject: Re: efficient count/join query