pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Bax <fbax@sympatico.ca>
To: pgsql-sql@postgresql.org
Subject: Re: Counting days ...
Date: Sat, 15 Mar 2008 12:05:17 -0400
Message-ID: <47DBF3BD.9080306@sympatico.ca> (raw)
In-Reply-To: <200803141925.26039.aarni@kymi.com>
References: <200803132025.27821.aarni@kymi.com>
	<200803141713.40589.aarni@kymi.com>
	<47DAA330.8070409@sympatico.ca>
	<200803141925.26039.aarni@kymi.com>

Aarni Ruuhimäki wrote:
> So the WHERE clause would go like:
> 
> group_id = 1 AND res_start_day < '$date1' AND res_end_day >= '$date1' [AND 
> region_id = $region_id] [AND company_id = $company_id] [AND product_id = 
> $product_id]
> OR 
> group_id = 1 AND res_start_day = '$date1' AND res_end_day >= '$date1' [AND 
> region_id = $region_id] [AND company_id = $company_id] [AND product_id = 
> $product_id]
> OR
> group_id = 1 AND res_start_day >= '$date1' AND res_start_day < '$date2' AND 
> res_end_day >= '$date1' [AND region_id = $region_id] [AND company_id = 
> $company_id] [AND product_id = $product_id]


This is smaller; and should be equivalent:

group_id = 1 AND
( res_start_day <= '$date1' AND res_end_day >= '$date1'
OR
res_start_day >= '$date1' AND res_start_day < '$date2' )
[AND region_id = $region_id]
[AND company_id = $company_id]
[AND product_id =  $product_id]



view thread (13+ messages)  latest in thread

Message-ID: <47DBF3BD.9080306@sympatico.ca>
Permalink:  ../47DBF3BD.9080306@sympatico.ca/
Also on:    postgresql.org/message-id/47DBF3BD.9080306@sympatico.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fbax@sympatico.ca
  Subject: Re: Counting days ...
  In-Reply-To: <47DBF3BD.9080306@sympatico.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox