pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: T E Schmitz <mailreg@numerixtechnology.de>
To: Martin Knipper <martin@mk-os.de>
To: pgsql-sql@postgresql.org
Subject: Re: COUNT(*) to find records which have a certain number of
Date: Mon, 27 Sep 2004 10:45:01 +0100
Message-ID: <4157E11D.2030400@numerixtechnology.de> (raw)
In-Reply-To: <414F08FD.3080200@mk-os.de>
References: <414F02FF.8000603@numerixtechnology.de>
	<414F08FD.3080200@mk-os.de>

Hallo Martin,

Martin Knipper wrote:

> Am 20.09.2004 18:19 schrieb T E Schmitz:
> 
>>>I want to select only those BRAND/MODEL combinations, where the MODEL 
>>>has more than one TYPE, but only where one of those has TYPE_NAME='xyz'.
>>>I am not interested in MODELs with multiple TYPEs where none of them are 
>>>called 'xyz'.
>>
>>
> 
> Try this:
> 
> select b.brand_name,m.model_name,count(*) from model m inner join
> brand b on m.brand_fk=b.brand_pk inner join type t on
> m.model_pk=t.model_fk where t.type_name='xyz' group by
> b.brand_name,m.model_name having count(m.model_name)>0;
> 

Sorry, no, this doesn't work. It definitely doesn't return the required 
resultset. It just returns all BRAND_NAME,MODEL_NAME for all Models that 
have a Type with TYPE_NAME='xyz'.

-- 


Regards/Gruß,

Tarlika Elisabeth Schmitz



view thread (16+ messages)  latest in thread

Message-ID: <4157E11D.2030400@numerixtechnology.de>
Permalink:  ../4157E11D.2030400@numerixtechnology.de/
Also on:    postgresql.org/message-id/4157E11D.2030400@numerixtechnology.de

 · 

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: mailreg@numerixtechnology.de, martin@mk-os.de
  Subject: Re: COUNT(*) to find records which have a certain number of
  In-Reply-To: <4157E11D.2030400@numerixtechnology.de>

* 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