Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 454B29F9C8A for ; Mon, 20 Aug 2007 22:21:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 91957-02 for ; Mon, 20 Aug 2007 22:21:34 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.176]) by postgresql.org (Postfix) with ESMTP id D8AE59F98AA for ; Mon, 20 Aug 2007 22:21:41 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id m38so989842waf for ; Mon, 20 Aug 2007 18:21:40 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=bh6Z5F6zFT4oH/gP+rdM6ChqkL6K0+qKd4Ptg16TV9Y6b+5/eZ4MvTl8VqtgwzeUpUKOM3Qanq+OVhi4oAp4eKMK4AbDI7BAn3KJOWHcSGzQPEgIYXwPF+Am9f0tS41kIAh2y9aMvgca2qIyYM/nJs67400MfOpXAXdZpJz/odI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=d3IJc3ZNz2gAS4gm01gKnuhghjVjDNMt07yjaEAsELS32aCmUKH/0Q2rpH+ypPtkrDNE1uDKQTvycYdYiDZOAlwwszYi76GwOKjaq1a3mXBSRNVFYS/yer0mL91xUi08DlmVWJn4ID1omnOf3shPewxb4kUs3T/IQSe6l8/gsRc= Received: by 10.114.183.1 with SMTP id g1mr783903waf.1187659300266; Mon, 20 Aug 2007 18:21:40 -0700 (PDT) Received: by 10.114.80.13 with HTTP; Mon, 20 Aug 2007 18:21:40 -0700 (PDT) Message-ID: Date: Tue, 21 Aug 2007 11:21:40 +1000 From: novice To: "Michael Glaesemann" Subject: Re: Join query help Cc: pgsql-sql@postgresql.org In-Reply-To: <4416C45B-CCC2-44AC-AA92-92500CF21BF5@seespotcode.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4416C45B-CCC2-44AC-AA92-92500CF21BF5@seespotcode.net> X-Google-Sender-Auth: 6dad25188dab8047 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/161 X-Sequence-Number: 29099 On 21/08/07, Michael Glaesemann wrote: > Now here's where I started having trouble. I can't figure out how to > get 2 observations for week 29 (record_id 1 & 3) and 8 for week 30 > (record_id 2). Assuming the data is wrong (which is admittedly a poor > assumption), I moved ahead. > > week_no | count(record_id | count(observation_id) | sum(score_id) > > where = '1' > > 2007, 30 | 2 | 8 | 6 > > 2007, 29 | 1 | 2 | 1 For week 29, there were 1 SAFE observation out of the 2 observations and for week 30, there were 6 SAFE obseravations out of the 8 observations. Hope this helps. Thanks!