[SQL] SQL query with Overlapping date time ranges

2013-04-18 Thread chinnaobi
I have a temporary table with columnszone_name, nodeid, nodelabel, nodegainedservice, nodelostserviceZone1, 3, Windows-SRV1, "2012-11-27 13:10:30+08", "2012-11-27 13:00:40+08"Zone1, 5, Windows-SRV2, "2012-12-20 13:10:30+08", "2012-12-18 13:00:40+08"Many zones and many no

Re: [SQL] sql query problem

2012-01-17 Thread David Johnston
On Jan 17, 2012, at 8:35, Andreas Kretschmer wrote: > Alok Thakur wrote: > >> Dear, >> >> I am trying to provide you as much details as possible. >> >> answer` ( >> `id` int(10) NOT NULL AUTO_INCREMENT, >> `question_id` int(10) NOT NULL, >> `user_id` int(10) NOT NULL, >> `answer` int(10)

Re: [SQL] sql query problem

2012-01-17 Thread Andreas Kretschmer
Alok Thakur wrote: > Dear, > > I am trying to provide you as much details as possible. > > answer` ( > `id` int(10) NOT NULL AUTO_INCREMENT, > `question_id` int(10) NOT NULL, > `user_id` int(10) NOT NULL, > `answer` int(10) NOT NULL, -> > `status` tinyint(1) NOT NULL, --> Status wil

Re: [SQL] sql query problem

2012-01-17 Thread Alok Thakur
FROM > UserTable INNER JOIN result ON UserTable.id = result.user_id > > Sent from my Windows Phone > From: Alok Thakur > Sent: 15/01/2012 22:08 > To: pgsql-...@postgresql.org > Subject: [SQL] sql query problem > Dear All, > > I have two tables one contains details of user an

Re: [SQL] sql query problem

2012-01-15 Thread Misa Simic
result.user_id Sent from my Windows Phone From: Alok Thakur Sent: 15/01/2012 22:08 To: pgsql-sql@postgresql.org Subject: [SQL] sql query problem Dear All, I have two tables one contains details of user and other contains result. The details are: 1. UserTable - id, name, phone 2. result - id,

Re: [SQL] sql query problem

2012-01-15 Thread Oliveiros
What does a 0 state mean? Failed? And a 1 state? Passed? Best, Oliveiros 2012/1/14 Alok Thakur > Dear All, > > I have two tables one contains details of user and other contains > result. The details are: > 1. UserTable - id, name, phone > 2. result - id, question_id, user_id, status (0 or 1) >

[SQL] sql query problem

2012-01-15 Thread Alok Thakur
Dear All, I have two tables one contains details of user and other contains result. The details are: 1. UserTable - id, name, phone 2. result - id, question_id, user_id, status (0 or 1) I want the list like this: User Id Name Attended Failed Passed but i could not find the way to do this

[SQL] SQL Query Performance - what gives?

2009-08-18 Thread Karl Denninger
Let's take the following EXPLAIN results: ticker=# explain select * from post, forum where forum.name = post.forum and invisible <> 1 and to_tsvector('english', message) @@ to_tsquery('violence') order by modified desc limit 100;

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 vehic

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 ---+---+-++---

[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 - create replace function

2007-12-20 Thread Richard Huxton
Iuri Sampaio wrote: Hi all, I created a script to install postgresql. One of the steps is to run a sql query. the problem is that i need to run the query as postgres user, plus it needs to be at psql shell prompt command line, i.e: Why does it need to be at the psql prompt? I expected somet

[SQL] sql query - create replace function

2007-12-19 Thread Iuri Sampaio
Hi all, I created a script to install postgresql. One of the steps is to run a sql query. the problem is that i need to run the query as postgres user, plus it needs to be at psql shell prompt command line, i.e: # from your shell prompt enter: $ psql # From the psql prompt enter the follow plp

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 (e

Re: [SQL] SQL query to display like this

2007-08-24 Thread Richard Huxton
RPK wrote: select PaySlipDate,EmpID, case ADCode when 'GPF' then ADAmount else 0 end GPF, case ADCode when 'GPF.ADV' then ADAmount else 0 end 'GPF.ADV' from EmpSalaryRecord It is showing like this: Date EmpID GPFGPF.ADV - 01-Jul-07 101

[SQL] SQL query to display like this

2007-08-24 Thread RPK
I have a table with records like this: Date EmpIDADCode ADAmount - 01-Jul-07101 GPF150 01-Jul-07102 GPF.ADV100 01-Jul-07103 GPF200 01-jul-07104

[SQL] SQL Query Validate Records Multiple Tables - Help Needed

2007-05-19 Thread Paul251
Hello... I am trying to validate a asset number (10 Characters) from one table to another table. Problem is they are in two different DB's and haven't done that before? Basically trying to take record 1 from Table 1/DB1 and validate it against record 1 in Table 2/DB2 if the record doesn't exist i

Re: [SQL] SQL Query Validate Records Multiple Tables - HelpNeeded

2007-05-16 Thread Bart Degryse
I'm working on something similar at the moment. Don't know about you, but I have an additional problem: I have to deal with rather large datasets (>2 recs per query) to be moved between the two databases (Oracle and PostgreSQL in my case). After doing lots of performance test, for me the con

Re: [SQL] SQL Query Validate Records Multiple Tables - Help Needed

2007-05-15 Thread Rodrigo De León
On May 15, 8:17 am, Paul251 <[EMAIL PROTECTED]> wrote: > Hello... > > I am trying to validate a asset number (10 Characters) from one table > to another table. Problem is they are in two different DB's and > haven't done that before? > > Basically trying to take record 1 from Table 1/DB1 and valida

Re: [SQL] SQL Query Newbie Help

2006-03-27 Thread Jim C. Nasby
On Fri, Mar 24, 2006 at 02:29:10PM -0800, Stephan Szabo wrote: > > On Fri, 24 Mar 2006, Julie Robinson wrote: > > > This works, but is there a better solution? > > > > select * > > from quality_control_reset T > > where date = ( > > select max(date) > > from quality_control_reset > >

Re: [SQL] SQL Query Newbie Help

2006-03-24 Thread Stephan Szabo
On Fri, 24 Mar 2006, Julie Robinson wrote: > This works, but is there a better solution? > > select * > from quality_control_reset T > where date = ( > select max(date) > from quality_control_reset > where qualitycontrolrange = T.qualitycontrolrange); If you can use PostgreSQL extens

Re: [SQL] SQL Query Newbie Help

2006-03-24 Thread Julie Robinson
This works, but is there a better solution? select * from quality_control_reset T where date = ( select max(date) from quality_control_reset where qualitycontrolrange = T.qualitycontrolrange); Julie Robinson wrote: Given the two tables at the bottom of this email, I'm having trouble c

[SQL] SQL Query Newbie Help

2006-03-24 Thread Julie Robinson
Given the two tables at the bottom of this email, I'm having trouble coming up with a SQL statement that returns all rows in the quality_control_reset table where there is only one row for the most recent quality_control_range. Help? Example: In table quality_control_reset: id | timesta

[SQL] Sql Query help: Remove Sub Selects

2005-07-13 Thread Rob
Hi Gang, I'm trying to optimize a query: This query below returns something like this: event_id | eu_tid | event_name | event_when | day | mon | start | end|event_users | contact_phone| contact_pager | num_opps --++-

Re: [SQL] SQL Query question

2005-06-30 Thread Nick Stone
Thanks for the reply at least that explains it. Nick -Original Message- From: Richard Huxton [mailto:[EMAIL PROTECTED] Sent: 30 June 2005 12:22 To: Nick Stone Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] SQL Query question Nick Stone wrote: > Hi > > Whilst I'm not n

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 an

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 > (

[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."K

Re: [SQL] SQL query help?

2005-03-07 Thread Michael Fuhr
On Mon, Mar 07, 2005 at 04:22:15PM -, John McGough wrote: > +---+---++-+--+ > | ID | JobID | UserID | Finished | Comment | > +---+---++-+--+ This table output doesn't look like PostgreSQL's usual format. > but I keep getting MySQL err

Re: [SQL] SQL query help?

2005-03-07 Thread Keith Worthington
John McGough wrote: SELECT Count(*) FROM Work WHERE (UserID='user1' AND MAX(Finished)=0) Work:- +---+---++-+--+ | ID | JobID | UserID | Finished | Comment | +---+---++-+--+ | 1 | 1| user1 | 0 | ...| | 2

[SQL] SQL query help?

2005-03-07 Thread John McGough
SELECT Count(*) FROM Work WHERE (UserID='user1' AND MAX(Finished)=0) Work:- +---+---++-+--+ | ID | JobID | UserID | Finished | Comment | +---+---++-+--+ | 1 | 1| user1 | 0 | ...| | 2 | 1|

Re: [SQL] SQL Query Performance tips

2005-01-31 Thread Michael Ossareh
Hi PFC Thanks for this! It has sped up complete - now in fact there is no delay! A few tweaks had to be made to the code ; here it is: select breakdown.alignment, sum(cnt) as num FROM ( (select alignment.name as class, count(1) as cnt from weapons, alignment where weapons

Re: [SQL] SQL Query Performance tips

2005-01-15 Thread PFC
If I understand well a person has all the free weapons which have a level <= to his own level, and of course all the weapons he bought. 1) get da weapons One query can only use one index. Bad for you ! Let's split the free and non-free weapons. 1a) free weapons S

[SQL] SQL Query Performance tips

2005-01-14 Thread Michael Ossareh
Hi All, I have a partial table structure as below tbl_user_main user_id pk user_level references tbl_level user_class references tbl_class user_level references tbl_level tbl_level level_id pk level_name level_points tbl_weapon wea

[SQL] SQL Query Timeouts

2004-04-26 Thread Dan Field
I have a problem with a select statement that I am using in a web search engine. I have the following SQL: SELECT da_records.TITLE_EN AS TITLE, da_records.AUTHOR_EN AS AUTHOR, da_records.DESCRIPTION_EN AS DESCRIPTION, da_records.PUBLISHER_EN AS PUBLISHER, da_records.URL_EN AS URL, da_reco

Re: [SQL] SQL Query

2004-03-23 Thread Bruno Wolff III
On Tue, Mar 23, 2004 at 20:02:32 +, beyaNet Consultancy <[EMAIL PROTECTED]> wrote: > Hi, > I am trying to create a query which basically goes along the lines of: > > INSERT INTO tableX ( COL1, COL2 ) VALUES ( x, y ) where COL1 !=x and > COL2 !=Y > > So, insert a record into tableX where th

[SQL] SQL Query

2004-03-23 Thread beyaNet Consultancy
Hi, I am trying to create a query which basically goes along the lines of: INSERT INTO tableX ( COL1, COL2 ) VALUES ( x, y ) where COL1 !=x and COL2 !=Y So, insert a record into tableX where there is not already an existence of COL1 and COL2 Can this be done as I have described or is there a mor

Re: [SQL] SQL query --- big question???

2004-03-12 Thread Richard Huxton
On Friday 12 March 2004 14:36, Andrei Bintintan wrote: > Hi to all, > > I have a big question. > > Can I write a query/function/agregate function (whatever) so that I can > return the result of a query in a single line? I don't know if this is > possible to be made and please if it is not possible

[SQL] SQL query --- big question???

2004-03-12 Thread Andrei Bintintan
Hi to all,   I have a big question.   Can I write a query/function/agregate function (whatever) so that I can return the result of a query in a single line? I don't know if this is possible to be made and please if it is not possible please say.     I better give an example:   table (id, nam

Re: [SQL] SQL query seach + rearranging results

2004-02-17 Thread Richard Huxton
On Monday 16 February 2004 16:07, lowdog wrote: > hey guys! > > I need your help in writing a php name-day searcher script. Actually, you probably want a mysql list - this is a PostgreSQL list. However, from what I can understand of your problem I think the easiest solution for you might be to o

[SQL] SQL query seach + rearranging results

2004-02-17 Thread lowdog
hey guys! I need your help in writing a php name-day searcher script. here's what ive done: i have the hostname, login and pw defined in a file, this one calls it: then i made the query, where (sorry for not translating the variable names, would be easier for you to understand ) the "nev

Re: [SQL] SQL query

2004-02-04 Thread daq
PC> Hello, PC> I would like to retrieve all the records from table A which have given PC> lang_id and its modification date is later then modification date of PC> the same id record with lang_id='pl'. PC> Example: PC> table A - data example PC> == PC> id | modification_d

[SQL] SQL query

2004-02-03 Thread Paul Czubilinski
Hello, I would like to retrieve all the records from table A which have given lang_id and its modification date is later then modification date of the same id record with lang_id='pl'. Example: table A - data example == id | modification_date | lang_id +---

Re: [SQL] SQL Query for Top Down fetching of childs

2004-01-29 Thread Kumar
ED]> Sent: Thursday, January 29, 2004 3:57 PM Subject: Re: [SQL] SQL Query for Top Down fetching of childs > On Thursday 29 January 2004 06:11, Kumar wrote: > > Dear Friends, > > > > Postgres 7.3.4 on RH Linux 7.2. > > > > I need a query to get the Childs of a par

Re: [SQL] SQL Query for Top Down fetching of childs

2004-01-29 Thread Richard Huxton
On Thursday 29 January 2004 06:11, Kumar wrote: > Dear Friends, > > Postgres 7.3.4 on RH Linux 7.2. > > I need a query to get the Childs of a parent (Top down analysis). Need to > list all the departments(Childs) of a parent organization. The table > structure is Two places to look for examples: 1

[SQL] SQL Query for Top Down fetching of childs

2004-01-28 Thread Kumar
Dear Friends,   Postgres 7.3.4 on RH Linux 7.2.   I need a query to get the Childs of a parent (Top down analysis). Need to list all the departments(Childs) of a parent organization. The table structure is   CREATE TABLE organization(  entity_id int4,  entity_name varchar(100),  entity_type

Re: [SQL] sql query with join and parameter in postgresql function

2004-01-16 Thread Philippe Lang
> > I thought a view would be more appropriate, but > > if I'm not wrong, a view does not accept any parameter > > as input... > > But you can just define the view and select it with a WHERE clause with > your parameter, just like a normal table. Would that help? Thanks! That's perfect. I join in

Re: [SQL] sql query with join and parameter in postgresql function

2004-01-16 Thread Michael Glaesemann
On Jan 16, 2004, at 8:30 PM, Philippe Lang wrote: Hello, I'd like to write a function similar to that: CREATE FUNCTION public.report_join_parameter(char(6)) RETURNS ??? AS Do I ***HAVE TO*** define a composite type for the columns my function

[SQL] sql query with join and parameter in postgresql function

2004-01-16 Thread Philippe Lang
Hello, I'd like to write a function similar to that: CREATE FUNCTION public.report_join_parameter(char(6)) RETURNS ??? AS ' SELECT tableA.field1, tableA.field2, tableB.field1, tableB.field2, tableC.field1, tableC.field2, FROM tableA INNER JOIN

Re: [SQL] SQL query problem

2003-10-09 Thread Stuart Barbee
Marek, Not sure but, try switching the lines db_data.mda_mod_con _CON, db_data.set_mda_fue _FUE with db_data.set_mda_fue _FUE, db_data.mda_mod_con _CON so there query is: SELECT _CON.con_id, _MOD.mod_ty, _VER.version, _YEA.year, _CON.dri_id, _CON.man_cod, _ENG.eng_p

Re: [SQL] SQL query problem

2003-10-09 Thread Bruno Wolff III
On Thu, Oct 09, 2003 at 20:52:58 +0100, Marek Lewczuk <[EMAIL PROTECTED]> wrote: > Hello, > I'm in the middle of the migration process from MySQL to PostgreSQL and > I cannot understand why this query isn't working (in MySQL it's working > fine). PG returns: ERROR: Relation "_con" does not exist

[SQL] SQL query problem

2003-10-09 Thread Marek Lewczuk
Hello, I'm in the middle of the migration process from MySQL to PostgreSQL and I cannot understand why this query isn't working (in MySQL it's working fine). PG returns: ERROR: Relation "_con" does not exist This is my query: SELECT _CON.con_id, _MOD.mod_ty, _VER.version, _YEA.year, _C

Re: [SQL] sql query

2002-12-11 Thread Christoph Haller
> > Hi I have a problem forming a query > I have 3 tables salary(hrs, clock_in , clock_out) > Break ( date, employe_id, net_time, break_in, break_out) > Employee(employee_id, pay_rate, name) > > I need to get an hourly report till the current time for that day > stating name, hour, no of hours, sal

[SQL] sql query

2002-12-10 Thread Vijay Uppal
Hi I have a problem forming a query I have 3 tables salary(hrs, clock_in , clock_out) Break ( date, employe_id, net_time, break_in, break_out) Employee(employee_id, pay_rate, name)   I need to get an hourly report till the current time for that day stating name, hour, no of hours, sal

Re: [SQL] SQL QUERY

2002-12-03 Thread Achilleus Mantzios
mply and nicely use sequences. > Pedro Igor > > - Original Message - > From: "Achilleus Mantzios" <[EMAIL PROTECTED]> > To: "Pedro Igor" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Tuesday, December 03, 2002 11:05

Re: [SQL] SQL QUERY

2002-12-03 Thread Achilleus Mantzios
On Tue, 3 Dec 2002, Pedro Igor wrote: > I have the following function: > CREATE FUNCTION public.auto_incremento() RETURNS trigger AS ' > begin > new.id = (select (max(id) + 1) from teste); > return new; > end;' LANGUAGE 'plpgsql' > > I created a trigger that uses this function, but i want to the f

[SQL] SQL QUERY

2002-12-03 Thread Pedro Igor
I have the following function: CREATE FUNCTION public.auto_incremento() RETURNS trigger AS 'beginnew.id = (select (max(id) + 1) from teste);return new;end;' LANGUAGE 'plpgsql' I created a trigger that uses this function, but i want to the function be usefull for all tables and not only to

Re: [SQL] SQL query help!

2002-11-28 Thread Arcadius A.
Hello! "Luis Sousa" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > This is a cryptographically signed message in MIME format. > > --ms080209060900030807050408 > Content-Type: text/plain; charset=us-ascii; format=flowed > Content-Transfer-Encoding: 7

Re: [SQL] SQL query help!

2002-11-27 Thread Luis Sousa
Tell me what did you try with limit and group by. Where's IN, why don't you use EXISTS instead. It runs much master ! Regards, Luis Sousa Arcadius A. wrote: Hello! I hope that someone here could help. I'm using PostgreSQL7.1.3 I have 3 tables in my DB: the tables are defined in the following

[SQL] SQL query help!

2002-11-26 Thread Arcadius A.
Hello! I hope that someone here could help. I'm using PostgreSQL7.1.3 I have 3 tables in my DB: the tables are defined in the following way: CREATE TABLE category( id SERIAL NOT NULL PRIMARY KEY, // etc etc ) ; CREATE TABLE subcategory( id SERIAL NOT NULL PRIMARY KEY, categoryid int CONSTRAI

Re: [SQL] SQL Query

2001-09-12 Thread Miguel González
Sorry If i didnt make clear which are the fields and which are the tables. The tables are the ones "underlined", so I have cdroms, items, cdroms_items, loans and reservations. I just left the important fields in order not to confuse the people, and just wrote the name of the fields that are the p

[SQL] SQL Query

2001-09-11 Thread Miguel González
Dear all, I want to do a query to my PostgreSQL database. I want to use it in a PHP web client that I have got, but also I have tried in the back-end. I have the following tables on my database ( I translate the field names from Spanish into English) cdroms --- code_cdroms items -

[SQL] sql query

2001-02-12 Thread manjul katare
sir , kindly send me the solution of the above query. 1. To calculate th no. of days between 01/01/2000 to 03/02/2001. 2. TO calculate th time in newfoundland from centra standard time from 02-22-97 ,05.00 am. _ Get Your Priv

Re: [SQL] SQL Query Results

2001-01-24 Thread Christopher Sawtell
On Wed, 24 Jan 2001 18:02, wrote: > I want to show a certain person the commands I type and the query results, > and I want to save them in a file. I tried \e filename and \E filename and > its not working. Can someone please help me?? I don't know if this is available on your particular machine

[SQL] SQL Query Results

2001-01-24 Thread
I want to show a certain person the commands I type and the query results, and I want to save them in a file. I tried \e filename and \E filename and its not working. Can someone please help me??

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Jie Liang
Hope it helps: 1. If you use GROUP, the select list should sum|count|max ..., no single field. 2. If you use NULL, the condition should be field IS [NOT] NULL, = NULL will give the wrong answer. Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 O

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Jie Liang
I hope it may help: 1. if you use group clause in a select stmt, the select list must be agregate function such as sum(field),count(field), max(field)..., cannot use field. 2. for field have NULL field, should use field IS NULL, = NULL will give you wrong result! Jie LIANG Internet Products In

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Stephan Szabo
On Tue, 19 Dec 2000 [EMAIL PROTECTED] wrote: > Hello there > > I have a question regarding a SQL statement. > > When I execute (and that's what I need) > > SELECT Zylinder.Z_durch_soll, Zylinder.Z_id, Zylinder.Z_durch_ist, > ((Zylinder.Z_durch_soll+0.12) - Zylinder.Z_durch_ist) AS durchmesserd

[SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread juerg . rietmann
Hello there I have a question regarding a SQL statement. When I execute (and that's what I need) SELECT Zylinder.Z_durch_soll, Zylinder.Z_id, Zylinder.Z_durch_ist, ((Zylinder.Z_durch_soll+0.12) - Zylinder.Z_durch_ist) AS durchmesserdelta, (Zylinder.Z_durch_soll+0.12) AS effektiv FROM Auftrag,Zy

Re: [SQL] SQL Query using time

2000-12-12 Thread Blaise Carrupt
> Is it possible to carry out the comparison in the following manner > select name from table where 00:12 is between 23:58 and 00:30 You could try something like WHERE ('00:12' BETWEEN startTime AND endTime AND startTime <= endTime) OR ('00:12' NOT BETWEEN endTime AND startTime

[SQL] SQL Query using time

2000-12-12 Thread Karyn Keatley
Hi, I am attempting to write a sql query that compares times on a 24 hr clock eg 09:00<16:30 and 21:00>16:30 09:00 is the start time and 16:30 is the end time. The problem is that if the start time is 23:58 and the end time is 00:30 (next day) is there any way to carry out this comparison withou

Re: [SQL] sql query not using indexes

2000-09-22 Thread Stephan Szabo
On Fri, 22 Sep 2000, Tom Lane wrote: > indexscans; the current code may have overcorrected a shade, but I think > it's closer to reality than 6.5 was. > > As Hiroshi already commented, the difference in results suggests that > the desired data is very nonuniformly scattered in the table. 7.0 >

Re: [SQL] sql query not using indexes

2000-09-22 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: >> Ok I agree with you on the real database there are 127,300 rows and there >> are certanly a great number of rows > 'AAA'. But, supose I make a query >> select * from table where code > 'AAA' limit 10. it will read the entire >> table only to give me the

RE: [SQL] sql query not using indexes

2000-09-21 Thread Hiroshi Inoue
> -Original Message- > From: Sergio de Almeida Lenzi > > On Wed, 20 Sep 2000, Stephan Szabo wrote: > > > On Wed, 20 Sep 2000, User Lenzi wrote: > > > > > if I start a query: > > > > > > explain select * from teste where login = 'xxx' > > > results: > > > Index Scan using teste1 on teste

Re: [SQL] sql query not using indexes

2000-09-21 Thread Stephan Szabo
On Thu, 21 Sep 2000, Sergio de Almeida Lenzi wrote: > > > On a machine running version 6.5 both queries results index scan. > > > > > > this results that the version 6.5 is faster than version 7.0.2 on this > > > kind of > > > query. > > > > > > > > > Any explanation??? > > > > Have you done

Re: [SQL] sql query not using indexes

2000-09-21 Thread Sergio de Almeida Lenzi
On Wed, 20 Sep 2000, Stephan Szabo wrote: > On Wed, 20 Sep 2000, User Lenzi wrote: > > > if I start a query: > > > > explain select * from teste where login = 'xxx' > > results: > > Index Scan using teste1 on teste (cost=0.00..97.88 rows=25 ) > > > > > > however a query: > > explain selec

Re: [SQL] sql query not using indexes

2000-09-20 Thread Mitch Vincent
i" <[EMAIL PROTECTED]> Cc: "pgsql-sql" <[EMAIL PROTECTED]> Sent: Wednesday, September 20, 2000 11:23 AM Subject: Re: [SQL] sql query not using indexes > On Wed, 20 Sep 2000, User Lenzi wrote: > > > if I start a query: > > > > explain select * fro

Re: [SQL] sql query not using indexes

2000-09-20 Thread Stephan Szabo
On Wed, 20 Sep 2000, User Lenzi wrote: > if I start a query: > > explain select * from teste where login = 'xxx' > results: > Index Scan using teste1 on teste (cost=0.00..97.88 rows=25 ) > > > however a query: > explain select * from teste where login > 'AAA' > results: > Seq Scan on teste .

[SQL] sql query not using indexes

2000-09-20 Thread User Lenzi
Hello, I am using last version of postgresql, 7.0.2 on a FreeBSD or Linux box I create a table: create table teste ( login text, datein datetime); create index teste1 on teste (login); if I start a query: explain select * from teste where login = 'xxx' results: Index Scan using te