Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8eXn-0000kj-9p for pgsql-sql@arkaria.postgresql.org; Thu, 21 Feb 2013 22:23:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U8eXm-0002Mv-Pb for pgsql-sql@arkaria.postgresql.org; Thu, 21 Feb 2013 22:23:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8eXl-0002Mk-ON for pgsql-sql@postgresql.org; Thu, 21 Feb 2013 22:23:09 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8eXj-0008Lc-5m for pgsql-sql@postgresql.org; Thu, 21 Feb 2013 22:23:09 +0000 Received: by mail-wg0-f49.google.com with SMTP id 15so22263wgd.28 for ; Thu, 21 Feb 2013 14:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:references:in-reply-to:mime-version :content-transfer-encoding:content-type:message-id:cc:x-mailer:from :subject:date:to; bh=ygDAyEBIwwvQfG7ton04PkLp8dJCarL8J/e9eTLpMU8=; b=waxNrRYn+J2UaY5wUMTsOm26SD9YizpzDvyr+7ru+wbHmdmB+QkXENYFZPCBb3uuQe VCuFTmafSNI5yoNc4/F/QqJ5IU5wkFy5fRtyC3pPKZnOSNlJvUl3Lskr0oU+vuoZbl0i h5l9gEpWu2NJ1NvofzMERyRRxQw7m7WG44kDVQziRIev7hvo7vo9EGm9cIPKo07TF7yW ojUCH+g6W1MMEUpQUefjpbX3MDYyWKq6DIaPogLzH0dtSvoJdZH5obdodRRTs87C+faS T65AWJlWvmEpr7OTGJmhOJ3AGNUvrl7MwwIsGerGtwhT3DEpiiUmc4r25L5BfZA5yKXD 2FlQ== X-Received: by 10.180.89.101 with SMTP id bn5mr44721131wib.14.1361485386350; Thu, 21 Feb 2013 14:23:06 -0800 (PST) Received: from [10.33.173.239] (177.26.136.95.rev.vodafone.pt. [95.136.26.177]) by mx.google.com with ESMTPS id cf8sm206389wib.1.2013.02.21.14.23.01 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Feb 2013 14:23:05 -0800 (PST) References: <76AB0A60-BB3E-4674-881A-F0DF0ECE7F0B@gmail.com> <8D0E5D045E36124A8F1DDDB463D548557D1618F45F@mxsvr1.is.inps.co.uk> <8D0E5D045E36124A8F1DDDB463D548557D1618F461@mxsvr1.is.inps.co.uk> In-Reply-To: <8D0E5D045E36124A8F1DDDB463D548557D1618F461@mxsvr1.is.inps.co.uk> Mime-Version: 1.0 (iPhone Mail 8L1) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Message-Id: Cc: Russell Keane , "deneroteam@gmail.com" , "pgsql-sql@postgresql.org" X-Mailer: iPhone Mail (8L1) From: Oliver d'Azevedo Cristina Subject: Re: need help Date: Thu, 21 Feb 2013 22:26:11 +0000 To: Russell Keane X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Sorry, why do you need the joins? Best, Oliver Enviado via iPhone Em 21/02/2013, =C3=A0s 09:28 PM, Russell Keane e= screveu: >>> Now I really don't know how to do this. >>>=20 >>> can you advise me more ? >>>=20 >>>=20 >>> Thanks, >>>=20 >>> Dhaval >>=20 >>=20 >> I think these are the sqls you are looking for: >>=20 >> SELECT pm.id as move_id, p.id as product_id, l.id as location_id >> FROM product_move pm inner join product p on pm.product_id =3D p.id inne= r join location l on pm.destination_location =3D l.id >> and datetime BETWEEN '2010-1-01' AND '2012-12-31' >=20 >=20 > Sorry, that should have been: >=20 > For your 2 examples: >=20 > SELECT pm.id as move_id, p.id as product_id, l.id as location_id > FROM product_move pm inner join product p on pm.product_id =3D p.id inner= join location l on pm.destination_location =3D l.id > and datetime < '2012-11-30' >=20 > SELECT pm.id as move_id, p.id as product_id, l.id as location_id > FROM product_move pm inner join product p on pm.product_id =3D p.id inner= join location l on pm.destination_location =3D l.id > and datetime < '2012-12-31' >=20 > I'm not what the use of the 'from' date is in your examples. > Do you need to know the final destination of the product in that time per= iod? > Or every destination location of the product in that time period? >=20 > Regards, >=20 > Russell Keane > INPS >=20 > Follow us on twitter | visit www.inps.co.uk >=20 >=20 >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql