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

[SQL] Query question

2012-01-27 Thread John Tuliao
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

[SQL] Query question

2008-05-22 Thread Medi Montaseri
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 serial, name varchar(20) ); create table T1_T2 ( id serial,

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 serial, name

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 wrote:

Re: [SQL] sql query question ?

2007-12-31 Thread Trilok Kumar
Dear Shane, Thanks for the reply and your observation about the word i have used. It is idle odometer reading. The actual Scenario is that the vehicle is taken by the driver. When he comes the next day. He is suppose to login again. Here i am trying to find out how much distance has the

[SQL] sql query question ?

2007-12-29 Thread Trilok Kumar
Hi All, I have a table called vehicle_duty_cycle_summary vehicle_master_id | starting_odometer | ending_odometer | login_time | logout_time ---+---+-++ 4 |

Re: [SQL] sql query question ?

2007-12-29 Thread Shane Ambler
Trilok Kumar wrote: Hi All, I have a table called vehicle_duty_cycle_summary vehicle_master_id | starting_odometer | ending_odometer | login_time | logout_time

Re: [SQL] SQL query question

2007-10-07 Thread Rodrigo De León
On Sep 21, 12:09 am, [EMAIL PROTECTED] wrote: Write the query (or queries if necessary) needed to count the number of employees in each employee's department who are paid more than their manager. SELECT e.dept, COALESCE (SUM (1), 0) AS n FROM employees e JOIN employees m ON

[SQL] SQL Query question

2005-06-30 Thread Nick Stone
Hi Whilst I'm not new to SQL I am reasonably new to Postgres and as such I have a question on the following query: SELECT tbl1.TermTypeID, tbl1.ParentID, tbl1.KeywordID, tbl1.Term, tbl2.KeywordID FROM Terms As tbl1 LEFT JOIN SearchStore As tbl2 ON tbl1.KeywordID =

Re: [SQL] SQL Query question

2005-06-30 Thread Peter Eisentraut
Am Donnerstag, 30. Juni 2005 11:27 schrieb Nick Stone: SELECT tbl1.TermTypeID, tbl1.ParentID, tbl1.KeywordID, tbl1.Term, tbl2.KeywordID FROM Terms As tbl1 LEFT JOIN SearchStore As tbl2 ON tbl1.KeywordID = tbl2.KeywordID WHERE (tbl1.TermTypeID = 200) AND

Re: [SQL] SQL Query question

2005-06-30 Thread Richard Huxton
Nick Stone wrote: Hi Whilst I'm not new to SQL I am reasonably new to Postgres and as such I have a question on the following query: FROM Terms As tbl1 LEFT JOIN SearchStore As tbl2 ON tbl1.KeywordID = tbl2.KeywordID AND tbl2.StockID = 1 Why does the above query work fine and the

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

[SQL] Query question

2005-04-20 Thread Stéphane RIFF
Hi , I have table that represent a switch activity like this : | date| state | | 2005-04-20 17:00:00 | 0 | | 2005-04-20 17:00:15 | 0 | | 2005-04-20 17:00:30 | 1 | | 2005-04-20 17:00:45 | 1 | | 2005-04-20 17:01:00 | 1 | | 2005-04-20

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.stateA2.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