X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E0E599DCA83 for ; Mon, 6 Mar 2006 13:04:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56159-01 for ; Mon, 6 Mar 2006 13:04:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) by postgresql.org (Postfix) with ESMTP id 6C1059DCA1D for ; Mon, 6 Mar 2006 13:04:16 -0400 (AST) Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP with MS-WebStorage 6.0.6249 Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; 06 Mar 2006 09:04:10 -0800 Subject: Re: DATE SQL From: Mark Lewis To: wanpeng Cc: pgsql-jdbc@postgresql.org In-Reply-To: <01ec01c6410a$36814e00$4d06050a@WANP> References: <01ec01c6410a$36814e00$4d06050a@WANP> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Organization: MIR3, Inc. Date: Mon, 06 Mar 2006 09:04:10 -0800 Message-Id: <1141664650.17684.143.camel@archimedes> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-22) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.27 required=5 tests=[AWL=-0.007, MAILTO_TO_SPAM_ADDR=0.276, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 0.27 X-Spam-Level: X-Archive-Number: 200603/26 X-Sequence-Number: 14807 Well, in pure SQL I don't think you could do it without resorting to ugly tricks like defining an all_days table that had one row per day in your range, then doing something like, "select from all_days a join xxx x where a.day >=3D x.start_date and a.day <=3D x.end_date" So . . . don't do that. What you want isn't really a pure relational operation, so SQL isn't the right language for it. Either do it in your application code, or write a server-side function. In either case, this is more of a pgsql-general question, since it's not specific to JDBC at all. -- Mark Lewis On Mon, 2006-03-06 at 18:39 +0800, wanpeng wrote: > I want a result like >=20 > '2006-03-01' > '2006-03-02' > '2006-03-03'=20 > '2006-03-04'=20 >=20 >=20 > FROM table xxx >=20 > =E2=80=A6=E2=80=A6| start_date | end_date |=E2=80=A6=E2=80=A6 > | '2006-03-01' | '2006-03-04'| >=20 > how can I write the sql >=20 > thanks >=20 > ----------------------------------------------- > wanp2005@gmail.com =20 > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings