X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A0281D1C9E1 for ; Tue, 20 Apr 2004 11:42:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 63510-10 for ; Tue, 20 Apr 2004 11:42:23 -0300 (ADT) Received: from happy.onesystem.ca (happy.onesystem.ca [205.206.61.17]) by svr1.postgresql.org (Postfix) with ESMTP id 36BABD1B9A6 for ; Tue, 20 Apr 2004 11:42:19 -0300 (ADT) Received: from elb_lx.onesystem.ca ([10.1.1.50] helo=onesystem.com) by happy.onesystem.ca with asmtp (Exim 4.14) id 1BFwS6-0001II-Bo; Tue, 20 Apr 2004 08:42:22 -0600 Message-ID: <408536CD.5020105@onesystem.com> Date: Tue, 20 Apr 2004 08:42:21 -0600 From: Edmund Bacon User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) X-Accept-Language: en-us, en MIME-Version: 1.0 To: P A Cc: pete@tkins.com, pgsql-sql@postgresql.org Subject: Re: Can someone tell me why this statement is failing? References: <20040419203150.77559.qmail@web41112.mail.yahoo.com> In-Reply-To: <20040419203150.77559.qmail@web41112.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/190 X-Sequence-Number: 17565 Your end time minutes is NULL, comparing NULL to anything (even NULL itself) yields NULL so you either need to: SELECT * FROM ... WHERE ... AND (end_time_minutes IS NULL OR end_time_minutes <= '1082375100'); or SELECT * FROM ... WHERE ... AND coalsece(end_time_minutes, 0) <= '1082375100'; P A wrote: >Can anyone tell me why this SQL statement is not >matching with the row from the table below? I think >I'm going mad! > >##################################### >SQL Statement >##################################### > >SELECT * FROM t_bell_schedule WHERE calendar_day = >'2004-04-12' AND start_time_minutes >= '1082374200' >AND end_time_minutes <= '1082375100'; > >##################################### >Current DB Data to match >##################################### > > calendar_day | period_letter | start_time_minutes | >end_time_minutes >--------------+---------------+--------------------+------------------ > 2004-04-12 | B | 1082374440 | > 1082377320 > >##################################### >DB Structure >##################################### > > Column | Type | > Modifiers >--------------------+-----------------------------+-------------------------------------------------------------------------------- > bell_schedule_uid | integer | >not null default >nextval('public.t_bell_schedule_bell_schedule_uid_seq'::text) > calendar_day | date | > period_letter | character varying(4) | > period | character varying(4) | > start_time | time without time zone | > end_time | time without time zone | > total_minutes | integer | > activestatus | integer | > datecreated | timestamp without time zone | > datemodified | timestamp without time zone | > start_time_minutes | integer | > end_time_minutes | integer | > > >Cheers, >Pete > > > > > >__________________________________ >Do you Yahoo!? >Yahoo! Photos: High-quality 4x6 digital prints for 25¢ >http://photos.yahoo.com/ph/print_splash > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > -- Edmund Bacon