pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: union with count?
Date: Wed, 28 Mar 2007 18:19:06 +0200
Message-ID: <20070328161906.GA17735@KanotixBox> (raw)
In-Reply-To: <460A8865.3070005@fmed.uba.ar>
References: <460A75ED.6070501@fmed.uba.ar>
	<20070328142444.GA20168@a-kretschmer.de>
	<460A8865.3070005@fmed.uba.ar>

Gerardo Herzig <gherzig@fmed.uba.ar> schrieb:

> Thanks! But now i have another problem related with count():
> 
> select page_id, word, word_position, count(page_id) from (select * from 
> search_word('word1', 'table1') union search_word('word2', 'table2')) foo 
> group by page_id;
> 
> and gives me "foo.word must appear in GROUP clause or be used in an 
> aggregate function"
> 
> And i want to group by page_id only, because that is what i need to count. 
> Tips here?

You can't aggregate without grouping the not-aggregated columns.
Expand your 'group by' with word and word_position.


Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°



view thread (5+ messages)

Message-ID: <20070328161906.GA17735@KanotixBox>
Permalink:  ../20070328161906.GA17735@KanotixBox/
Also on:    postgresql.org/message-id/20070328161906.GA17735@KanotixBox

 · 

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: akretschmer@spamfence.net
  Subject: Re: union with count?
  In-Reply-To: <20070328161906.GA17735@KanotixBox>

* 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