Re: [SQL] need help

2013-02-22 Thread Russell Keane
etime FROM product_move where datetime < '2012-11-01' group by product_id ) X on pm.product_id = X.product_id and pm.datetime = X.datetime Thus you will know where every product was coming into the period and every subsequent destination it was moved to within that per

Re: [SQL] need help

2013-02-22 Thread Russell Keane
> Sorry, why do you need the joins? > > Best, > Oliver Strictly speaking, for the examples and results given, the joins are pointless when you can get all the info from the 'move' table (but then the problem is like the 'hello world' of SQL) But then the other 2 tables are completely redundant

Re: [SQL] need help

2013-02-21 Thread Russell Keane
roduct p on pm.product_id = p.id inner join location l on pm.destination_location = l.id and datetime < '2012-12-31' 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 period? Or every desti

Re: [SQL] need help

2013-02-21 Thread Russell Keane
uct_id, l.id as location_id FROM product_move pm inner join product p on pm.product_id = p.id inner join location l on pm.destination_location = l.id and datetime BETWEEN '2010-1-01' AND '2012-12-31' Regards, Russell Keane INPS Follow us on twitter | visit www.inps.co.uk -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] FW: view derived from view doesn't use indexes

2012-07-27 Thread Russell Keane
Hi Tom, Thanks for that, that was exactly the issue. It absolutely is IMMUTABLE and changing it from VOLATILE has fixed the issue. Much appreciated, Russell, -Original Message- From: Tom Lane [mailto:t...@sss.pgh.pa.us] Sent: 26 July 2012 16:52 To: Russell Keane Cc: pgsql-sql

[SQL] FW: view derived from view doesn't use indexes

2012-07-26 Thread Russell Keane
ove this causes up problems as we have to create all views to point directly to the table rather than deriving them from other views. Any ideas? Regards, Russell Keane Registered name: In Practice Systems Ltd. Registered address: The Bread Factory, 1a Broughton S

[SQL] Updatable view should truncate table fields

2011-11-08 Thread Russell Keane
values (2, '123456'); --This line fails obviously Regards, Russell Keane INPS Subscribe to the Vision e-newsletter<http://www.inps4.co.uk/news/enewsletter/> Subscribe to the Helpline Support Bulletin<http://www.inps4.co.uk/my_vision/helpline/support-bulletins> [ci

[SQL] Create Type with typmod_in

2011-11-04 Thread Russell Keane
t_function, TYPMOD_IN = auto_trunc_char_modifier_in ); Regards, Russell Keane INPS Subscribe to the Vision e-newsletter<http://www.inps4.co.uk/news/enewsletter/> Subscribe to the Helpline Support Bulletin<http://www.inps4.co.uk/my_vision/helpline/support-bulletins> [cid:image001