[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 basic question

2012-12-28 Thread Andreas Kretschmer
Maybe something like: test=*# select * from foo; label | id | distance | side ---++--+-- 15 | 119006 | 0.10975569030617 |1 14 | 119006 | 0.11844830745091 |0 16 | 119006 | 0.17624040731777 |0 20 | 119006 | 0.39363711745035 |

Re: [SQL] sql basic question

2012-12-28 Thread Antonio Parrotta
Hello Andreas, apologize for the misunderstanding. Hope to clarify now. For each ID I want a min and max for each SIDE. I have about 160K records like this: label | id | distance | side ---++---+-- 15 | 119006 | 0.10975569030617 |

Fwd: Re: [SQL] sql basic question

2012-12-28 Thread Andreas Kretschmer
sorry, only a private replay and not to the list -- Ursprüngliche Nachricht -- Von: Andreas Kretschmer An: Antonio Parrotta Datum: 28. Dezember 2012 um 15:19 Betreff: Re: [SQL] sql basic question Hi, your question was: "What I want to achieve is a result table with min an

Re: [SQL] sql basic question

2012-12-28 Thread Antonio Parrotta
Hi Andreas, Anton, I did some test and both queries didn't worked. Maybe I was not clear with the example provided. My table contains more than 160K records with SIDE 0, 1, -1, 2, -2, 3 and -3. Example provided is a very small subset. *Andrea's *query is failing because it is getting only distinc

Re: [SQL] sql basic question

2012-12-28 Thread Anton Gavazuk
Antonio, but then you can do join between minmax select and source table by distance and get required columns... Thanks, Anton On Dec 28, 2012, at 12:43, Antonio Parrotta wrote: Hi Anton, I need column LABEL and ID as well. By grouping on SIDE these column cannot be included in the query.

Re: [SQL] sql basic question

2012-12-28 Thread Antonio Parrotta
Hi Anton, I need column LABEL and ID as well. By grouping on SIDE these column cannot be included in the query. Thanks - Antonio On 28 December 2012 12:38, Anton Gavazuk wrote: > Do the child Select min, max from... Group by side > > Then you can do whatever is required... > > Thanks, > Ant

Re: [SQL] sql basic question

2012-12-28 Thread Anton Gavazuk
Do the child Select min, max from... Group by side Then you can do whatever is required... Thanks, Anton On Dec 28, 2012, at 12:23, Antonio Parrotta wrote: Hi All, I have this table: LABEL ID Distance SIDE "15"; 119006; 0.10975569030617;1

[SQL] sql basic question

2012-12-28 Thread Antonio Parrotta
Hi All, I have this table: LABEL ID Distance SIDE "15"; 119006; 0.10975569030617;1 "14"; 64054;0.118448307450912; 0 "16"; 64055;0.176240407317772; 0 "20"; 64057;0.39363711745035;0 "19";

Re: [SQL] SQL View to PostgreSQL View

2012-02-28 Thread Igor Neyman
RROR:  schema "dbo" does not exist LINE 15:  from  dbo.kbsites a inner join dbo.kbsites b on a.chr=b.chr                 ^ ** Error ** ERROR: schema "dbo" does not exist SQL state: 3F000 Character: 761 >> First, I assume you are converting your view from

Re: [SQL] SQL View to PostgreSQL View

2012-02-28 Thread Mario Dankoor
Hi Rehan, Whilst I'm not sure what you exactly mean with ', while this is working perfectly fine in sql,..', it's kind of odd that you get result when you execute the sql. I'd suggest looking at your search_path (show search_path), which normally resolves to 'user', 'public'; If you do h

Re: [SQL] SQL View to PostgreSQL View

2012-02-27 Thread Adrian Klaver
On Sunday, February 26, 2012 10:50:16 am Rehan Saleem wrote: > Hi , > I am trying to convert sql > view to postgresql view but i am getting the > following error i dont know how > to handle dbo. > in postgresql and when i remove dbo. from table name then view got created > but it does not show any

[SQL] SQL View to PostgreSQL View

2012-02-26 Thread Rehan Saleem
Hi , I am trying to convert sql view to postgresql view but i am getting the following error i dont know how to handle dbo. in postgresql and when i remove dbo. from table name then view got created but it does not show any data, while this is working perfectly fine in sql, here is my code and er

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

Re: [SQL] SQL gotcha

2011-02-14 Thread Achilleas Mantzios
Στις Tuesday 15 February 2011 01:29:25 ο/η Dean Gibson (DB Administrator) έγραψε: > As you all know, when you specify an alias for a table or column name, > the keyword "AS" is usually optional. I personally like to always > include the "AS" keyword, if for no other reason than readability, and

[SQL] SQL gotcha

2011-02-14 Thread Dean Gibson (DB Administrator)
As you all know, when you specify an alias for a table or column name, the keyword "AS" is usually optional. I personally like to always include the "AS" keyword, if for no other reason than readability, and I presume that always using "AS" might catch some syntactic errors as well. However,

Re: [SQL] sql disaster - subquery error but delete continues

2010-09-10 Thread Thomas Kellerer
Greg Caulton, 10.09.2010 11:46: delete from form_record_details where form_record_id in (select form_record_id from forms where form_id= 40003656) Seems fine at 1am. However the subquery has a typo in it - there is no form_record_id in the forms table But rather than psql throwing an error..

[SQL] sql disaster - subquery error but delete continues

2010-09-10 Thread Greg Caulton
delete from form_record_details where form_record_id in (select form_record_id from forms where form_id= 40003656) Seems fine at 1am. However the subquery has a typo in it - there is no form_record_id in the forms table But rather than psql throwing an error... it deletes every row in the form_

Re: [SQL] SQL Developer accessing PostgreSQL

2010-03-31 Thread Thomas Kellerer
Snyder, James, 29.03.2010 18:33: Hello, Is there a way to configure Oracle’s SQL Developer to access a PostgreSQL database? Thanks,Jim As others have pointed out, it's not possible. The Postgres Wiki contains a list of GUI Tools that work with Postgres: http://wiki.postgresql.org/wiki/Commu

Re: [SQL] SQL Developer accessing PostgreSQL

2010-03-31 Thread Jose Alarcon
  Just drop in the jdbc jar       From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Snyder, James Sent: Monday, March 29, 2010 11:34 AM To: pgsql-sql@postgresql.org Subject: [SQL] SQL Developer accessing PostgreSQL   Hello, Is

Re: [SQL] SQL Developer accessing PostgreSQL

2010-03-30 Thread Hiltibidal, Rob
I recommend Aqua Data Studio Just drop in the jdbc jar From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Snyder, James Sent: Monday, March 29, 2010 11:34 AM To: pgsql-sql@postgresql.org Subject: [SQL] SQL Developer accessing PostgreSQL

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-30 Thread Thomas Kellerer
Snyder, James, 29.03.2010 18:25: Thanks for all the dialog on this subject. My "version" was derived from the postgreSQL's .jar file (specifically named "postgresql-8.4-701.jdbc4.jar") that I'm using. When I do the following: select version() I get the following: PostgreSQL 8.3.6 Then you

Re: [SQL] SQL Developer accessing PostgreSQL

2010-03-29 Thread silly sad
On 03/29/10 20:33, Snyder, James wrote: Hello, Is there a way to configure Oracle’s SQL Developer to access a PostgreSQL database? IMHO, no. And (even if it possible) it is completely useless, since the Postgresql has the "psql" program far better than any oracle tool and than all oracle too

[SQL] SQL Developer accessing PostgreSQL

2010-03-29 Thread Snyder, James
Hello, Is there a way to configure Oracle's SQL Developer to access a PostgreSQL database? Thanks,Jim

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-29 Thread Snyder, James
ng to check this out. Thanks...Jim -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Thomas Kellerer Sent: Friday, March 26, 2010 3:15 AM To: pgsql-sql@postgresql.org Subject: Re: [SQL] SQL syntax rowcount value as an extra colu

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-26 Thread Thomas Kellerer
Jayadevan M, 26.03.2010 07:56: Thank you for setting that right. Apologies for not checking version. The orginal poster stated that he is using 8.4, so that solution will work for him. Thomas -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription:

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
Hi, >It works, but you should use a recent version: >test=*# select count(1) over (), i from foo; > count | i >---+ > 8 | 1 > 8 | 2 > 8 | 3 > 8 | 6 > 8 | 7 > 8 | 9 > 8 | 13 > 8 | 14 >(8 rows) > test=*# select version(); >

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread A. Kretschmer
In response to Jayadevan M : > Hi, > I don't think so. > Oracle - > SQL> select count(*) over () as ROWCOUNT , first_name from people; > > ROWCOUNT FIRST_NAME > -- > - > --- > 6 Mary

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
Regards, Jayadevan From: Thomas Kellerer To: pgsql-sql@postgresql.org Date: 26/03/2010 03:26 Subject: Re: [SQL] SQL syntax rowcount value as an extra column in the result set Sent by:pgsql-sql-ow...@postgresql.org Snyder, James wrote on 25.03.2010 22:33: > I’m using Postg

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
such a query (cartesian join) Regards, Jayadevan From: "Snyder, James" To: Date: 26/03/2010 03:21 Subject: [SQL] SQL syntax rowcount value as an extra column in the result set Sent by:pgsql-sql-ow...@postgresql.org Hello I’m using PostgreSQL (8.4.701) and

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Thomas Kellerer
Snyder, James wrote on 25.03.2010 22:33: I’m using PostgreSQL (8.4.701) There is no such version. The current version is 8.4.3 On a side note, Oracle allows the following syntax to achieve the above: select count(*) over () as ROWCOUNT , first_name from people The same syntax will work on

[SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Snyder, James
Hello I'm using PostgreSQL (8.4.701) and Java (jdbc, postgresql-8.4-701.jdbc4.jar) to connect to the database. My question is: what is the SQL syntax for PostgreSQL to achieve the following: I want to receive the rowcount along with the rest of a result set. For example, let's say the following

[SQL] SQL code beautifier for PostgreSQL.

2010-03-16 Thread Dmitriy Igrishin
Hey all, Is there any good SQL code beautifier for PostgreSQL to use with Emacs or other text editors? Unfortunately, pg_dump(1) does not format views and rules... It would be nice if we could format unreadable views and rules definitions in favorite editor... Regards, Dmitriy Igrishin

Re: [SQL] SQL state 58P01 triggered by a database script execution

2009-12-09 Thread A. Kretschmer
In response to aymen marouani : > Thanks for the help, > > In deed I found those lines in my script > > "-- > -- TOC entry 25 (class 1255 OID 16409) > -- Dependencies: 6 > -- Name: bt_metap(text); Type: FUNCTION; Schema: public; Owner: postgres > -- > > CREATE FUNCTION bt_metap(relname text, OUT

Re: [SQL] SQL state 58P01 triggered by a database script execution

2009-12-09 Thread aymen marouani
Thanks for the help, In deed I found those lines in my script "-- -- TOC entry 25 (class 1255 OID 16409) -- Dependencies: 6 -- Name: bt_metap(text); Type: FUNCTION; Schema: public; Owner: postgres -- CREATE FUNCTION bt_metap(relname text, OUT magic integer, OUT version integer, OUT root integer,

Re: [SQL] SQL state 58P01 triggered by a database script execution

2009-12-09 Thread A. Kretschmer
In response to aymen marouani : > Hi, > > I have a database under Postgres v8.3 and I generated its backups script using > PGAdmin III. > I executed the same script under Postgres v8.2 in order to create the same > database but I get the following error > > " ERROR: could not access file "$libdir

[SQL] SQL state 58P01 triggered by a database script execution

2009-12-09 Thread aymen marouani
Hi, I have a database under Postgres v8.3 and I generated its backups script using PGAdmin III. I executed the same script under Postgres v8.2 in order to create the same database but I get the following error " ERROR: could not access file "$libdir/pageinspect": No such file or directory SQL s

Re: [SQL] SQL moving window averages/statistics

2009-10-01 Thread Andreas
Just 3 points ... 1) don't use "date" as a column name because it's a data type. 2) to_char(current_date, 'MM')||to_char(current_date, 'DD') is equivalent to to_char(current_date, 'MMDD') 3) you should get the same result with ... where icao='KSFO' and (EXTRACT (MONTH from d

Re: [SQL] SQL Subqueries on each result row

2009-09-24 Thread Mark J Camilleri
On Wed, Sep 23, 2009 at 6:33 PM, Jim wrote: > On Sep 23, 5:43 am, AnthonyV wrote: > > Hello, > > > > I have a table like : > > > >date|value > > --- > > 2009-09-19 | 1 > > 2009-09-20 | 2 > > 2009-09-21 | 6 > > 2009-09-22 | 9 > > 200

[SQL] SQL moving window averages/statistics

2009-09-23 Thread Kai Carter
Hi there, I'm currently have an sql statement that selects a week of descriptive statistics for various historical weather variables, sorted by date. SELECT to_char(date, 'MM')||to_char(date, 'DD') as date, max(tmax) as max_tmax, min(tmax) as min_tmax, avg(tmax) as mean_tmax, stddev(tmax)

Re: [SQL] SQL Subqueries on each result row

2009-09-23 Thread Jim
On Sep 23, 5:43 am, AnthonyV wrote: > Hello, > > I have a table like : > >    date        |    value > --- > 2009-09-19 |      1 > 2009-09-20 |      2 > 2009-09-21 |      6 > 2009-09-22 |      9 > 2009-09-23 |      1 > > I'd like a request which gives me the sum of each

[SQL] SQL Subqueries on each result row

2009-09-23 Thread AnthonyV
Hello, I have a table like : date|value --- 2009-09-19 | 1 2009-09-20 | 2 2009-09-21 | 6 2009-09-22 | 9 2009-09-23 | 1 I'd like a request which gives me the sum of each last n days. For example, if I want the sum of each 3 days,

[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 report

2009-08-02 Thread wkipjohn
Hi Rob, I have default B-Tree indexes created for each of the indexed columes and primary key columes. (No multiple columes indexe or NULL FIRST or DESC/ASC). I am using PostgreSQL 8.3 with the auto vacuum daemon on. I assume analyse will be automatically run to collect statistics for use b

Re: [SQL] SQL report

2009-08-02 Thread wkipjohn
Hi Steve, Thanks for you suggestions. In my senario, what is current depends on users. Because if user wants a status report at 00:00 1st Jan 2009, then 00:00 1st Jan 2009 is current. So it is not possible to flag any records as current unless the user tells us what is current. cheers Joh

Re: [SQL] SQL report

2009-07-31 Thread Rob Sargent
Did you look at the query plans for the various record counts? That might show which index is missing or misinformed :). I wonder if clustering the status table on objectid would help? This does then require maintenance so you might only load it at 75%. wkipj...@gmail.com wrote: Hi Rob,

Re: [SQL] SQL report

2009-07-30 Thread Steve Crawford
wkipj...@gmail.com wrote: I have the following senario. I have a tracking system. The system will record the status of an object regularly, all the status records are stored in one table. And it will keep a history of maximum 1000 status record for each object it tracks. The maximum objects t

Re: [SQL] SQL report

2009-07-30 Thread Rob Sargent
I would be curious to know the performance curve for let's say 20K, 40K , 60K, 80K, 100K records. And what sort of indexing you have, whether or not it's clustered, re-built and so on. One could envision partitioning the status table such that recent records were grouped together (on the assu

[SQL] SQL report

2009-07-29 Thread wkipjohn
I have the following senario. I have a tracking system. The system will record the status of an object regularly, all the status records are stored in one table. And it will keep a history of maximum 1000 status record for each object it tracks. The maximum objects the system will track is

WG: WG: [SQL] sql-porting-problem oracle to postgresql with UPDAT E/IS NOT NULL

2009-07-29 Thread Gau, Hans-Jürgen
he Nachricht- Von: nha [mailto:lyondi...@free.fr] Gesendet: Mittwoch, 29. Juli 2009 13:04 An: Gau, Hans-Jürgen Cc: PgSQL-sql Betreff: Re: WG: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL Hello again, Le 29/07/09 12:21, nha a écrit : > Hello, > > Le 29/07/09 11

Re: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread Daryl Richter
On Jul 28, 2009, at 5:10 PM, nha wrote: Hello, Le 28/07/09 14:25, Daryl Richter a écrit : On Jul 28, 2009, at 5:58 AM, Gau, Hans-Jürgen wrote: hello list, i have some problems with an sql-statement which runs on oracle but not on postgresql (i want update only if result of SELECT is not emp

Re: WG: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread nha
Hello again, Le 29/07/09 12:21, nha a écrit : > Hello, > > Le 29/07/09 11:48, Gau, Hans-Jürgen a écrit : >> Sorry, it's a lapse by copying and simplification the original version. that >> is correct: >> >> UPDATE table1 t1 >> SET (t1.id) = >> (SELECT t3.id FROM table2 t2,table

Re: WG: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread nha
Hello, Le 29/07/09 11:48, Gau, Hans-Jürgen a écrit : > Sorry, it's a lapse by copying and simplification the original version. that > is correct: > > UPDATE table1 t1 > SET (t1.id) = > (SELECT t3.id FROM table2 t2,table3 t3, table1 t1 > WHERE t3.field = t2.fie

WG: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread Gau, Hans-Jürgen
cht- Von: nha [mailto:lyondi...@free.fr] Gesendet: Dienstag, 28. Juli 2009 23:11 An: Gau, Hans-Jürgen Cc: PgSQL-sql Betreff: Re: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL Hello, Le 28/07/09 14:25, Daryl Richter a écrit : > > On Jul 28, 2009, at 5:58 AM,

Re: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-28 Thread nha
Hello, Le 28/07/09 14:25, Daryl Richter a écrit : > > On Jul 28, 2009, at 5:58 AM, Gau, Hans-Jürgen wrote: > >> hello list, >> i have some problems with an sql-statement which runs on oracle but >> not on postgresql (i want update only if result of SELECT is not >> empty, the SELECT-queries are

Re: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-28 Thread Daryl Richter
On Jul 28, 2009, at 5:58 AM, Gau, Hans-Jürgen wrote: hello list, i have some problems with an sql-statement which runs on oracle but not on postgresql (i want update only if result of SELECT is not empty, the SELECT-queries are identical): UPDATE table1 t1 SET (t1.id) =

[SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-28 Thread Gau, Hans-Jürgen
hello list, i have some problems with an sql-statement which runs on oracle but not on postgresql (i want update only if result of SELECT is not empty, the SELECT-queries are identical): UPDATE table1 t1 SET (t1.id) = (SELECT h.id FROM table2 t2,table3 t3, table1 t1

Re: [SQL] SQL File in encrypted form

2009-06-19 Thread Jasen Betts
On 2009-06-19, Jyoti Seth wrote: > This is a multipart message in MIME format. > > --=_NextPart_000_0001_01C9F0F8.92EE3490 > Content-Type: text/plain; > charset="us-ascii" > Content-Transfer-Encoding: 7bit > > Hi All, > > > > I want to send the sql script file to a client but wants to

[SQL] SQL File in encrypted form

2009-06-19 Thread Jyoti Seth
Hi All, I want to send the sql script file to a client but wants to hide the details in it. Can I send the sql script file in encrypted form which they can execute but can't view the details. Thanks, Jyoti

Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-04-02 Thread Tom Lane
Alvaro Herrera writes: > Another way to phrase the WHERE clause is with the OVERLAPS operator, > something like this: > WHERE (start_ts, end_ts) OVERLAPS ('2008-12-07 07:59:59', '2008-12-07 > 08:59:59') > What I'm not so sure about is how optimizable this construct is. Not at all :-( --- or a

Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-04-02 Thread Alvaro Herrera
James Kitambara wrote: > Dear Srikanth, > You can solve your problem by doing this > > THE SQL IS AS FOLLOWS >   ASSUME TIME INTERVAL 2008-12-07 07:59:59 TO 2008-12-07 08:58:59 AND THE > TABLE NAME time_interval > >  COUNT (*) FROM   >     (select customer_id, log_session_id, start_ts, end_ts ,

Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-04-02 Thread James Kitambara
From: Richard Huxton To: Srikanth Cc: pgsql-sql@postgresql.org Sent: Tuesday, 17 March, 2009 18:06:09 Subject: Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps Dear all, I have a table that records User Login Sessions with two timestamp

Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-03-18 Thread Srikanth
That did the job. Thanks. Am new to SQL, does not even know that there exists an Operator called OVERLAPS. Thanks Richard ../rssrik --- On Tue, 17/3/09, Richard Huxton wrote: From: Richard Huxton Subject: Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end tim

Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-03-17 Thread Richard Huxton
Srikanth wrote: > Dear all, > > I have a table that records User Login Sessions with two timestamp fields. > Basically Start of Session and End of a Session (start_ts and end_ts). Each > row in the table identifies a session which a customer has used. > > Data from the table (session): >

[SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-03-17 Thread Srikanth
Dear all, I have a table that records User Login Sessions with two timestamp fields. Basically Start of Session and End of a Session (start_ts and end_ts). Each row in the table identifies a session which a customer has used.  Data from the table (session): -  custo

Re: [SQL] SQL syntax I've been unable to figure out....

2008-12-25 Thread Rodrigo E. De León Plicet
2008/12/25 Karl Denninger : > Assuming a table containing: > > name text > address text > uri text > > I wish to run a query that will return those rows where: > > ("name" is not null) AND (distinct) (uri is the same for two or more entries > AND name is different between the two entries)) > > Exam

[SQL] SQL syntax I've been unable to figure out....

2008-12-25 Thread Karl Denninger
for the following Assuming a table containing: name text address text uri text I wish to run a query that will return those rows where: ("name" is not null) AND (distinct) (uri is the same for two or more entries AND name is different between the two entries)) Example data: george who 1 sa

Re: [SQL] SQL Statement Missing From Log

2008-10-27 Thread Tom Lane
Bryce Nesbitt <[EMAIL PROTECTED]> writes: > I'm getting a bunch of: > 2008-10-25 14:36:59 PDT ERROR: syntax error at or near "SET" at character 9 > 2008-10-25 14:36:59 PDT ERROR: syntax error at or near "fetch" at > character 9 > 2008-10-25 14:36:59 PDT ERROR: current transaction is aborted, co

[SQL] SQL Statement Missing From Log

2008-10-27 Thread Bryce Nesbitt
Dear Helpful People, I'm getting a bunch of: 2008-10-25 14:36:59 PDT ERROR: syntax error at or near "SET" at character 9 2008-10-25 14:36:59 PDT ERROR: syntax error at or near "fetch" at character 9 2008-10-25 14:36:59 PDT ERROR: current transaction is aborted, commands ignored until end of tr

Re: [SQL] SQL question....

2008-05-21 Thread Karl Denninger
Steve Midgley wrote: At 12:20 PM 5/21/2008, [EMAIL PROTECTED] wrote: Date: Wed, 21 May 2008 06:39:11 -0500 From: Karl Denninger <[EMAIL PROTECTED]> To: Gurjeet Singh <[EMAIL PROTECTED]> Cc: pgsql-sql@postgresql.org Subject: Re: SQL question Message-ID: <[EMAIL PROTECTED]> > Also, if you do

Re: [SQL] SQL question....

2008-05-21 Thread Steve Midgley
At 12:20 PM 5/21/2008, [EMAIL PROTECTED] wrote: Date: Wed, 21 May 2008 06:39:11 -0500 From: Karl Denninger <[EMAIL PROTECTED]> To: Gurjeet Singh <[EMAIL PROTECTED]> Cc: pgsql-sql@postgresql.org Subject: Re: SQL question Message-ID: <[EMAIL PROTECTED]> > Also, if you don't have it already, yo

Re: [SQL] SQL question....

2008-05-21 Thread Karl Denninger
Gurjeet Singh wrote: On Wed, May 21, 2008 at 8:33 AM, Karl Denninger <[EMAIL PROTECTED] > wrote: Gurjeet Singh wrote: On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED] > wrote: Gurjeet Singh wrote:

Re: [SQL] SQL question....

2008-05-21 Thread Gurjeet Singh
On Wed, May 21, 2008 at 8:33 AM, Karl Denninger <[EMAIL PROTECTED]> wrote: > Gurjeet Singh wrote: > > On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED]> > wrote: > >> Gurjeet Singh wrote: >> >>> On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]>> [EMAIL PROTECTE

Re: [SQL] SQL question....

2008-05-20 Thread Karl Denninger
Gurjeet Singh wrote: On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED] > wrote: Gurjeet Singh wrote: On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]

Re: [SQL] SQL question....

2008-05-20 Thread Gurjeet Singh
On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED]> wrote: > Gurjeet Singh wrote: > >> On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote: >> >> assuming the following schema: >> >>create table access (name text, address ip) >

Re: [SQL] SQL question....

2008-05-20 Thread Karl Denninger
Gurjeet Singh wrote: On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED] > wrote: assuming the following schema: create table access (name text, address ip) I want to construct a SELECT statement which will return ONLY tuples cont

Re: [SQL] SQL question....

2008-05-20 Thread Gurjeet Singh
On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]> wrote: > assuming the following schema: > > create table access (name text, address ip) > > I want to construct a SELECT statement which will return ONLY tuples > containing IP and name pairs IF there is an IP that has two o

Re: [SQL] SQL question....

2008-05-20 Thread Harold A. Giménez Ch.
I think this is what you're looking for: SELECT * FROM access WHERE ip IN(SELECT ip FROM access GROUP BY ip HAVING count(*) > 1) On Tue, May 20, 2008 at 3:17 PM, Karl Denninger <[EMAIL PROTECTED]> wrote: > chester c young wrote: > > create table access (name text, address ip) > > I

Re: [SQL] SQL question....

2008-05-20 Thread Karl Denninger
chester c young wrote: create table access (name text, address ip) I want to construct a SELECT statement which will return ONLY tuples containing IP and name pairs IF there is an IP that has two or more NAMEs associated with it. many ways: select a1.* from access a1 where exists(

Re: [SQL] SQL question....

2008-05-20 Thread chester c young
> create table access (name text, address ip) > > I want to construct a SELECT statement which will return ONLY tuples > containing IP and name pairs IF there is an IP that has two or more > NAMEs associated with it. > > many ways: select a1.* from access a1 where exists( select 1 from ac

[SQL] SQL question....

2008-05-20 Thread Karl Denninger
assuming the following schema: create table access (name text, address ip) I want to construct a SELECT statement which will return ONLY tuples containing IP and name pairs IF there is an IP that has two or more NAMEs associated with it. I've not figured out how to do this; I can get a

[SQL] SQL/XML Multi table join question

2008-04-16 Thread Mina R Waheeb
Hi all, I have the following tables (parent and two children) CREATE SEQUENCE person_seq; CREATE TABLE person( _id integer DEFAULT nextval('person_seq') NOT NULL, _timestamp TIMESTAMP NOT NULL, _lastModified TIMESTAMP NOT NULL, name VARCHAR(255) NOT NULL,

Re: [SQL] SQL standards in Mysql

2008-02-27 Thread Steve Crawford
Dean Gibson (DB Administrator) wrote: ...For example, I think phpBB is the only major message board software that supports PostgreSQL (see http://www.phpbb.com/about/features/compare.php ), and in fact has for some time. Of course, they have a DB abstraction layer (wow, what an concept!), whi

Re: [SQL] SQL standards in Mysql

2008-02-24 Thread Aarni Ruuhimäki
On Saturday 23 February 2008 07:50, Tom Lane wrote: >Hmm ... while ... > so I'm disinclined to throw the first > stone ... Meanwhile, Throw cones, not stones. http://cfx.kymi.com/lotsacones.jpg These things/projectiles hurt not so much. And it's fun ! BR, -- Aarni Ruuhimäki

Re: [SQL] SQL standards in Mysql

2008-02-22 Thread Tom Lane
Ken Johanson <[EMAIL PROTECTED]> writes: > Here's one Mysql developer's response to adding (fixing) the > integer/bigint/tinyint types to their CAST function: > http://bugs.mysql.com/bug.php?id=34562 Hmm ... while I'm certainly not someone to defend mysql on a regular basis, I can see their poin

Re: [SQL] SQL standards in Mysql

2008-02-22 Thread Scott Marlowe
On Fri, Feb 22, 2008 at 11:03 PM, Mail Delivery Subsystem <[EMAIL PROTECTED]> wrote: > This is an automatically generated Delivery Status Notification > > Delivery to the following recipient failed permanently: > > [EMAIL PROTECTED] > To: "Dean Gibson (DB Administrator)" <[EMAIL PROTECTED]>

Re: [SQL] SQL standards in Mysql

2008-02-22 Thread Scott Marlowe
On Fri, Feb 22, 2008 at 7:39 PM, Dean Gibson (DB Administrator) <[EMAIL PROTECTED]> wrote: > So, I went with PostgreSQL. Why? From the book, it was clear that > MySQL lacked so many features of a decent SQL DB. In particular (at the > time) VIEWs and sub-selects. Note that unless someone's d

Re: [SQL] SQL standards in Mysql

2008-02-22 Thread Dean Gibson (DB Administrator)
On 2008-02-22 16:13, Scott Marlowe wrote: There's example after example of things in the mysql bug database that should make anyone considering it as a database engine cringe and walk away shaking their head. I don't understand why anyone wanting a real SQL DB would pick MySQL. Four years ago

Re: [SQL] SQL standards in Mysql

2008-02-22 Thread Scott Marlowe
On Fri, Feb 22, 2008 at 1:57 PM, Alvaro Herrera <[EMAIL PROTECTED]> wrote: > Ken Johanson wrote: > > Here's one Mysql developer's response to adding (fixing) the > > integer/bigint/tinyint types to their CAST function: > > > > http://bugs.mysql.com/bug.php?id=34562 > > So they are anal too, bu

Re: [SQL] SQL standards in Mysql

2008-02-22 Thread Alvaro Herrera
Ken Johanson wrote: > Here's one Mysql developer's response to adding (fixing) the > integer/bigint/tinyint types to their CAST function: > > http://bugs.mysql.com/bug.php?id=34562 So they are anal too, but in the opposite direction? -- Alvaro Herrerahttp://www.

[SQL] SQL standards in Mysql

2008-02-22 Thread Ken Johanson
Here's one Mysql developer's response to adding (fixing) the integer/bigint/tinyint types to their CAST function: http://bugs.mysql.com/bug.php?id=34562 ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropria

Re: [SQL] Sql ORDER BY and ASC/DESC question

2008-01-30 Thread Gregory Stark
"Tom Lane" <[EMAIL PROTECTED]> writes: > Gregory Stark <[EMAIL PROTECTED]> writes: > >> ORDER BY >> CASE ? >> WHEN 1 THEN name ASC > > Uh, no, putting the ASC/DESC decoration inside a CASE like that is not > gonna work doh! I had a feeling something was wrong but couldn't put my finger on it

Re: [SQL] Sql ORDER BY and ASC/DESC question

2008-01-30 Thread Tom Lane
Gregory Stark <[EMAIL PROTECTED]> writes: > If you're not concerned with the planner being able to find indexes to satisfy > these orderings (ie, you don't mind always doing a sort) you could do > something like: > ORDER BY > CASE ? > WHEN 1 THEN name ASC > WHEN 2 THEN name DESC > WHEN 3 THE

Re: [SQL] Sql ORDER BY and ASC/DESC question

2008-01-30 Thread Gregory Stark
"A. Kretschmer" <[EMAIL PROTECTED]> writes: > am Wed, dem 30.01.2008, um 11:35:51 +0100 mailte Jaroslav Sivy folgendes: >> Hello everyone, >> >> I have following problem: am using pl/sql functions to trigger some >> sql code and i need to pass ORDER_BY column name and ASC/DESC sorting >> order a

Re: [SQL] Sql ORDER BY and ASC/DESC question

2008-01-30 Thread Bart Degryse
Actually there might be assuming your function is a set returning function. This example eg works perfectly and sorts the output of the function without having to use execute. CREATE TABLE "public"."error_types" ( "id" SERIAL, "errdesc" TEXT NOT NULL, "autofix" BOOLEAN DEFAULT false NOT

  1   2   3   4   5   6   7   >