Re: [SQL] Query question

2012-01-28 Thread Lew
On 01/26/2012 04:00 AM, John Tuliao wrote: I seem to have a problem with a specific query: The inside query seems to work on it's own: select prefix from john_prefix where strpos(jpt_test.number,john_prefix.prefix) = '1' order by char_length(john_prefix.prefix) desc limit 1 but when I execute

Re: [SQL] Query question

2008-05-22 Thread Medi Montaseri
Thanks Stephan, My real DDL include a forign key reference to T2.id and since I am ok with NULL value then the "left outer join" indeed have solved the problem. Thanks again Medi On Thu, May 22, 2008 at 2:50 PM, Stephan Szabo <[EMAIL PROTECTED]> wrote: > On Thu, 22 May 2008, Medi Montaseri wrot

Re: [SQL] Query question

2008-05-22 Thread Stephan Szabo
On Thu, 22 May 2008, Medi Montaseri wrote: > Hi, > I can use some help with the following query please. > > Given a couple of tables I want to do a JOIN like operation. Except that one > of the columns might be null. > > create table T1 ( id serial, name varchar(20) ); > create table T2 ( id seria

Re: [SQL] Query question

2005-04-21 Thread Stéphane RIFF
I do some tests with your first query and it seems to works. Thanks a lot for your answer, i will post the final thought later Thanks again bye Franco Bruno Borghesi wrote: If you have a row every 15 seconds, the answer is quite easy: SELECT A1.date FROM activity A1 LEFT JOIN activity A2 ON (A2.

Re: [SQL] Query question

2005-04-20 Thread Franco Bruno Borghesi
If you have a row every 15 seconds, the answer is quite easy: SELECT A1.date FROM activity A1 LEFT JOIN activity A2 ON (A2.date=A1.date-'15 secs'::interval) WHERE A1.state<>A2.state OR A2.state IS NULL ORDER BY 1 Now if you don't have a row every 15 seconds, the answer is a bit more