pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: Tomasz Myrta <jasiek@klaster.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: efficient count/join query
Date: Fri, 7 Feb 2003 14:21:14 +0000
Message-ID: <200302071421.14672.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <3E43B402.1090301@klaster.net>
References: <200302071007.28697.gary.stainburn@ringways.co.uk>
	<200302071209.55330.gary.stainburn@ringways.co.uk>
	<3E43B402.1090301@klaster.net>

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     




view thread (8+ messages)  latest in thread

Message-ID: <200302071421.14672.gary.stainburn@ringways.co.uk>
Permalink:  ../200302071421.14672.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/200302071421.14672.gary.stainburn@ringways.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gary.stainburn@ringways.co.uk, jasiek@klaster.net
  Subject: Re: efficient count/join query
  In-Reply-To: <200302071421.14672.gary.stainburn@ringways.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox