X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1435D52A2F for ; Wed, 30 Mar 2005 21:54:56 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41210-04 for ; Wed, 30 Mar 2005 20:54:54 +0000 (GMT) Received: from bramble.mmrd.com (bramble.mmrd.com [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 2A92752960 for ; Wed, 30 Mar 2005 21:54:53 +0100 (BST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id j2UKWBoJ006661 for ; Wed, 30 Mar 2005 15:32:13 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [10.225.10.110]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id j2UKsnM19433 for ; Wed, 30 Mar 2005 15:54:50 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id 12GRMAMN; Wed, 30 Mar 2005 15:54:46 -0500 Subject: save me from an unconstrained join From: Robert Treat To: pgsql-sql@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 30 Mar 2005 15:54:48 -0500 Message-Id: <1112216088.28936.404.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.031 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/397 X-Sequence-Number: 20876 It actually does what I want... but it offends my database sensibilities... :-) Heres the basics of the tables involved: CREATE TABLE bds_filesize ( bds_filesize_id serial name text NOT NULL, byte_limit integer NOT NULL, slots integer NOT NULL ); CREATE TABLE software ( software_binary_id serial, binary_file oid, filename text, filesize integer, checksum text ); query: select software_binary_id, min(byte_limit) from bds_filesize, software_binary where byte_limit > filesize GROUP BY software_binary_id; Basically each software is assigned a "class" based on the size of its binary into a predetermined range of classes that are defined as relative filesizes. The above query really does work... but istm I ought to be joining those tables somehow... any ideas? Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL