Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B42361337BCB for ; Mon, 10 Jan 2011 22:14:23 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 77819-10 for ; Tue, 11 Jan 2011 02:14:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wy0-f174.google.com (mail-wy0-f174.google.com [74.125.82.174]) by mail.postgresql.org (Postfix) with ESMTP id 216381337BCA for ; Mon, 10 Jan 2011 22:14:14 -0400 (AST) Received: by wyb28 with SMTP id 28so20017209wyb.19 for ; Mon, 10 Jan 2011 18:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=wvVCribgiddHwS51xS+UojUr5kyhGz8orn6qCsLK01o=; b=nD+I8ra/VRD+TZZy88YczLV/3iKQaXTOQMZnAGq/jozAFPWLD41haUO0pQ5gSJA8vO 1VSVySzgzXYtgtxar8cUaVhWj8D1F18gL0/mGB9/V+dFvWytvWB+pWTEKqvCv6ecDOJN ZgfdZvqOEmrrsQ2EiubnJqFFzeqc8v9WSGudE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=HTcBAunpLBke7FSd1ZsKyE7YcM+Dw9fl6HWoCKnyMJt+5N40aN5L0HugFnJYh7RJC3 SCI6KcUyrMjLDHKRMlllr4ovLBiqA7PRVWRtTjUMkTOEQ+zgBukPCcBz99bxfCewFJDb 4roHEmzbbF/ZgrwYNNZRtjsOcoCjNSWfGPEHw= Received: by 10.227.136.211 with SMTP id s19mr3291419wbt.177.1294712054411; Mon, 10 Jan 2011 18:14:14 -0800 (PST) Received: from [10.0.0.5] (heaton.plus.com [212.159.45.120]) by mx.google.com with ESMTPS id m13sm20562894wbz.21.2011.01.10.18.14.13 (version=SSLv3 cipher=RC4-MD5); Mon, 10 Jan 2011 18:14:13 -0800 (PST) Message-ID: <4D2BBCF4.8070905@gmail.com> Date: Tue, 11 Jan 2011 02:14:12 +0000 From: gvim User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: pgsql sql Subject: Find NOT NULLs in a group of 20 columns Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.598 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201101/22 X-Sequence-Number: 34969 I'm struggling to find anything other than a complex stored proc to do this: Out of a group of 20 columns return the rows in which: 1. Only 1 of the 20 columns IS NOT NULL 2. More than 1 of the 20 columns IS NOT NULL Any ideas? gvim