pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Inglis <david.inglis@ideloveto.com.au>
To: pgsql-sql@postgresql.org
Subject: Help with sql statement grouping and distinct
Date: Wed,  7 Jul 2004 14:38:42 +1000
Message-ID: <1089175122.40eb7e520e8d2@www.sportsupdate.com.au> (raw)

I want to be able to select a distinct group of rows from 2 tables and then once
selected to group and total the results from the previous sql statement I have
been trying the following



select a.id_fk_accommodation, a.id_fk_selection,a.type,sum(1) from
acommodationlog a, log l
    where (id_fk_accommodation) in
           (select distinct a.id_fk_accommodation, a.id_fk_selection, a.type,
l.sessionid from accommodationlog a, log l where a.id_fk_log = l.id_pk and
id_fk_accommodation = 159 )
   group by a.id_fk_accommodation,a.id_fk_selection,a.type

I know this won't work due to incorrect number of columns in the in statement
but how do I achieve the above

Any help appreciated Thanks

Regards


David Inglis





----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



Message-ID: <1089175122.40eb7e520e8d2@www.sportsupdate.com.au>
Permalink:  ../1089175122.40eb7e520e8d2@www.sportsupdate.com.au/
Also on:    postgresql.org/message-id/1089175122.40eb7e520e8d2@www.sportsupdate.com.au

 · 

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: david.inglis@ideloveto.com.au
  Subject: Re: Help with sql statement grouping and distinct
  In-Reply-To: <1089175122.40eb7e520e8d2@www.sportsupdate.com.au>

* 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