Re: [SQL] GROUP and ORDER BY

2011-11-08 Thread Tarlika Elisabeth Schmitz
On Tue, 08 Nov 2011 09:57:08 +0530 Robins Tharakan robins.thara...@comodo.com wrote: On 11/08/2011 02:50 AM, Tarlika Elisabeth Schmitz wrote: Hello, I would like to GROUP the result by one column and ORDER it by another: SELECT no, name, similarity(name, 'Tooneyvara') AS s FROM

[SQL] GROUP and ORDER BY

2011-11-07 Thread Tarlika Elisabeth Schmitz
, similarity(name, 'Tooneyvara') AS sim FROM vtown WHERE similarity(name, 'Tooneyvara') 0.4 ORDER BY no, sim DESC ) AS x ORDER BY sim Is that the best way to achieve this result? -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org

[SQL] extract some column/value pairs via hstore

2011-06-13 Thread Tarlika Elisabeth Schmitz
varying(3) NOT NULL, id serial NOT NULL, name character varying(50) NOT NULL, source character varying(2) NOT NULL ) -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref

Re: [SQL] Order of evaluation in triggers for checks on inherited table partitions

2011-05-27 Thread Tarlika Elisabeth Schmitz
On Fri, 27 May 2011 12:28:51 -0700 Kevin Crain kevin.cra...@gmail.com wrote: Is the order of evaluation for the trigger causing this error? Are you aware that triggers are executed in alphabetical order? I simply used RAISE to check the order of execution of my triggers: RAISE NOTICE '% % % %:

Re: [SQL] extracting location info from string

2011-05-26 Thread Tarlika Elisabeth Schmitz
On Thu, 26 May 2011 10:15:50 +1200 Andrej andrej.gro...@gmail.com wrote: On 26 May 2011 09:13, Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote: On Wed, 25 May 2011 09:25:48 -0600 Rob Sargent robjsarg...@gmail.com wrote: On 05/24/2011 10:57 AM, Lew wrote: Tarlika Elisabeth

Re: [SQL] extracting location info from string

2011-05-25 Thread Tarlika Elisabeth Schmitz
On Tue, 24 May 2011 12:57:57 -0400 Lew no...@lewscanon.com wrote: Tarlika Elisabeth Schmitz wrote: this was just a TEMPORARY table I created for quick analysis of my CSV data (now renamed to temp_person). Ah, yes, that makes much more sense. Temporary tables such as you describe can be very

Re: [SQL] extracting location info from string

2011-05-25 Thread Tarlika Elisabeth Schmitz
On Wed, 25 May 2011 09:25:48 -0600 Rob Sargent robjsarg...@gmail.com wrote: On 05/24/2011 10:57 AM, Lew wrote: Tarlika Elisabeth Schmitz wrote: CREATE TABLE person ( id integer NOT NULL, name character varying(256) NOT NULL, location character varying(256), CONSTRAINT person_pkey

Re: [SQL] extracting location info from string

2011-05-23 Thread Tarlika Elisabeth Schmitz
(country) REFERENCES country (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE RESTRICT, CONSTRAINT county_person_fk FOREIGN KEY (country, county) REFERENCES county (country, code) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, ); -- Best Regards, Tarlika Elisabeth

Re: [SQL] extracting location info from string

2011-05-23 Thread Tarlika Elisabeth Schmitz
On Mon, 23 May 2011 13:11:24 +1200 Andrej andrej.gro...@gmail.com wrote: On 23 May 2011 10:00, Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote: On Sun, 22 May 2011 21:05:26 +0100 Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote: A column contains location

[SQL] extracting location info from string

2011-05-22 Thread Tarlika Elisabeth Schmitz
(country, code), CONSTRAINT country_region_fk FOREIGN KEY (country) REFERENCES country (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE RESTRICT ) = System: PostgreSQL 8.4 -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make

Re: [SQL] extracting location info from string

2011-05-22 Thread Tarlika Elisabeth Schmitz
On Sun, 22 May 2011 21:05:26 +0100 Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote: A column contains location information, which may contain any of the following: 1) null 2) country name (e.g. France) 3) city name, region name (e.g. Bonn, Nordrhein-Westfalen) 4) city name, Rg

[SQL] Trigger: update if record exists

2011-05-09 Thread Tarlika Elisabeth Schmitz
I wrote a trigger function to convert inserts into updates if the record exists already. - I am not using rules because the table is populated via COPY. - I am employing a two-stage process (PERFORM, then UPDATE) because the update trigger might decide not to update after all, and therefore FOUND

Re: [SQL] data import via COPY, Rules + Triggers

2011-05-07 Thread Tarlika Elisabeth Schmitz
then insert into manager(name) values (NEW.manager_name); select into id_manager CURRVAL('manager_id_seq'); end if; INSERT INTO athlete (... manager_fk...) VALUES ( ... id_manager...); good luck! On Thu, May 5, 2011 at 6:21 PM, Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote

Re: [SQL] data import via COPY, Rules + Triggers

2011-05-07 Thread Tarlika Elisabeth Schmitz
On Wed, 4 May 2011 23:48:04 +0100 Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote: I have got a database that needs to be populated, first with historical data, then on a daily basis.[...] Once imported, data will neither be modified nor deleted. Data come in denormalized CSV

Re: [SQL] data import via COPY, Rules + Triggers

2011-05-05 Thread Tarlika Elisabeth Schmitz
Thank you for your help, Sergey. That certainly works. I was wondering whether the manager.id could maybe be obtained via INSERT ... RETURNING? -- Best Regards, Tarlika Elisabeth Schmitz On Thu, 5 May 2011 08:45:32 +0300 sergey kapustin kapustin.ser...@gmail.com wrote: Try using (select

[SQL] check constraint bug?

2011-05-05 Thread Tarlika Elisabeth Schmitz
horse ADD CONSTRAINT val_horse_stats CHECK (sex != 'f') OR (stats IS NULL)); -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] data import via COPY, Rules + Triggers

2011-05-04 Thread Tarlika Elisabeth Schmitz
, NEW.dad_id, NEW.sponsor_id, ?, NEW._received); ) System: PostgreSQL 8.3 no of users: 1 -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql

[SQL] data import: 12-hour time w/o AM/PM

2011-02-08 Thread Tarlika Elisabeth Schmitz
- it's always a set of events at one location spaced about 30min apart - the imported data are chained (have a link to previous/next event) Have you got any idea how I could tackle this problem -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql

Re: [SQL] data import: 12-hour time w/o AM/PM

2011-02-08 Thread Tarlika Elisabeth Schmitz
On Wed, 9 Feb 2011 08:21:47 +1300 Andrej andrej.gro...@gmail.com wrote: On 9 February 2011 07:14, Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote: From the date and time I want to create a timestamp. I know that - the events take place during the day, say between 10:30 and 22

Re: [SQL] data import: 12-hour time w/o AM/PM

2011-02-08 Thread Tarlika Elisabeth Schmitz
On Tue, 8 Feb 2011 18:38:44 - Oliveiros d'Azevedo Cristina oliveiros.crist...@marktest.pt wrote: - Original Message - From: Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de To: pgsql-sql@postgresql.org Sent: Tuesday, February 08, 2011 6:14 PM Subject: [SQL] data import: 12

Re: [SQL] psql -f COPY from STDIN

2010-11-13 Thread Tarlika Elisabeth Schmitz
On Fri, 12 Nov 2010 22:22:11 -0500 Tom Lane t...@sss.pgh.pa.us wrote: Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de writes: The following command works fine when pasing it to psql via the -c option: cat event.csv | \ psql -c COPY (event_id, event_name) FROM STDIN DELIMITER

Re: [SQL] psql -f COPY from STDIN

2010-11-13 Thread Tarlika Elisabeth Schmitz
On Sat, 13 Nov 2010 12:01:35 + Tarlika Elisabeth Schmitz postgres...@numerixtechnology.de wrote: I'd like the store the COPY command in a separate file without specifying an input file name. I want to feed it the data from the shell script that calls psql STDIN: All rows are read from

[SQL] psql -f COPY from STDIN

2010-11-12 Thread Tarlika Elisabeth Schmitz
STDIN DELIMITER AS ',' NULL AS '' cat event.csv | psql -f event.sql What's the problem? Many thanks in advance. -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql

Re: [SQL] identifying duplicates in table with redundancies

2010-09-29 Thread Tarlika Elisabeth Schmitz
On Wed, 29 Sep 2010 10:40:03 +0200 Andreas Schmitz mailingl...@longimanus.net wrote: On 09/28/2010 10:36 PM, Tarlika Elisabeth Schmitz wrote: On Tue, 28 Sep 2010 11:34:31 +0100 Oliveiros d'Azevedo Cristinaoliveiros.crist...@marktest.pt wrote: - Original Message - From: Tarlika

Re: [SQL] identifying duplicates in table with redundancies

2010-09-28 Thread Tarlika Elisabeth Schmitz
On Tue, 28 Sep 2010 11:34:31 +0100 Oliveiros d'Azevedo Cristina oliveiros.crist...@marktest.pt wrote: - Original Message - From: Tarlika Elisabeth Schmitz postgre...@numerixtechnology.de To: pgsql-sql@postgresql.org Sent: Monday, September 27, 2010 5:54 PM Subject: Re: [SQL] identifying

Re: [SQL] identifying duplicates in table with redundancies

2010-09-27 Thread Tarlika Elisabeth Schmitz
BY trainer_name-- the field you want to test for duplicates HAVING (COUNT(*) 1) ) z NATURAL JOIN student y What indices would you recommend for this operation? -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes

Re: [SQL] identifying duplicates in table with redundancies

2010-09-24 Thread Tarlika Elisabeth Schmitz
Dear Oliveiros, Thank you for taking the time to help. On Fri, 24 Sep 2010 11:22:21 +0100 Oliveiros d'Azevedo Cristina oliveiros.crist...@marktest.pt wrote: - Original Message - From: Tarlika Elisabeth Schmitz postgre...@numerixtechnology.de To: pgsql-sql@postgresql.org Sent: Thursday

Re: [SQL] identifying duplicates in table with redundancies

2010-09-24 Thread Tarlika Elisabeth Schmitz
quite upset about it! It took me a while to get my head round your outer query with the NATURAL JOIN between the student table and the nested query results. I have done table joins before but this solution would not have sprung to mind. -- Many thanks, Tarlika Elisabeth Schmitz -- Sent via

[SQL] identifying duplicates in table with redundancies

2010-09-23 Thread Tarlika Elisabeth Schmitz
on (trainer_id,trainer_name) trainer_id as id, trainer_name as name from student ) as trainer group by trainer.id having count (trainer.name) 1 ) ) as y order by trainer_id -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing

Re: [SQL] JOIN and aggregate problem

2009-02-23 Thread Tarlika Elisabeth Schmitz
On Fri, 20 Feb 2009 11:15:09 -0800 (PST) Stephan Szabo ssz...@megazone.bigpanda.com wrote: On Fri, 20 Feb 2009, Tarlika Elisabeth Schmitz wrote: I have 2 tables T1 and T2 T1 has the columns: D, S, C. The combination of D,S,C is unique. T2 has the columns: D, S, C, and boolean X

Re: [SQL] JOIN and aggregate problem

2009-02-23 Thread Tarlika Elisabeth Schmitz
On Fri, 20 Feb 2009 19:06:48 + Richard Huxton d...@archonet.com wrote: Tarlika Elisabeth Schmitz wrote: I have 2 tables T1 and T2 T1 has the columns: D, S, C. The combination of D,S,C is unique. T2 has the columns: D, S, C, and boolean X. The combination of D,S,C is not unique

Re: [SQL] JOIN and aggregate problem

2009-02-23 Thread Tarlika Elisabeth Schmitz
On Mon, 23 Feb 2009 15:44:05 + Richard Huxton d...@archonet.com wrote: Tarlika Elisabeth Schmitz wrote: On Fri, 20 Feb 2009 19:06:48 + Richard Huxton d...@archonet.com wrote: try something like: SELECT t1.d, t1.s, t1.c, count(*) FROM t1 LEFT JOIN ( SELECT d,s,c FROM t2

[SQL] JOIN and aggregate problem

2009-02-20 Thread Tarlika Elisabeth Schmitz
combinations in T2 where X = true. There might be no matching pair in T2 or there might be match but X is false. How can I express this? -- Best Regards, Tarlika Elisabeth Schmitz -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http

Re: [SQL] exclude part of result

2008-06-27 Thread Tarlika Elisabeth Schmitz
with this statement: 'select a,b,c, count()from product LEFT JOIN item on' P.M. --- On Thu 06/26, Tarlika Elisabeth Schmitz [EMAIL PROTECTED] wrote: From: Tarlika Elisabeth Schmitz [mailto: [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Date: Fri, 27 Jun 2008 00:35

Re: [SQL] exclude part of result

2008-06-27 Thread Tarlika Elisabeth Schmitz
On Fri, 27 Jun 2008 11:33:07 +0200 Harald Fuchs [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Tarlika Elisabeth Schmitz [EMAIL PROTECTED] writes: PRODUCT table : A B C 100 200 300 100 200 301 100 205 300 100 205 301 NAVIGATION table A B C #ITEMS 100 200 300 5

Re: [SQL] exclude part of result

2008-06-27 Thread Tarlika Elisabeth Schmitz
where t2.a = t1.a and t2.b = t1.b and t2.c = t1.c) Many thanks - there seems to be half a dozen ways of achieving the desired result! --- On Thu, 6/26/08, Tarlika Elisabeth Schmitz [EMAIL PROTECTED] wrote: From: Tarlika Elisabeth Schmitz [EMAIL PROTECTED] Subject: [SQL] exclude part of result

[SQL] exclude part of result

2008-06-26 Thread Tarlika Elisabeth Schmitz
can I achieve this? -- Best Regards, Tarlika Elisabeth Schmitz A: Because it breaks the logical sequence of discussion Q: Why is top posting bad? -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] 3 SELECTs rolled into 1 ?

2008-06-04 Thread Tarlika Elisabeth Schmitz
|| section.id as x FROM item LEFT JOIN product ON ... LEFT JOIN department ON ... LEFT JOIN section ON ... SELECT item.id department.id as x FROM item LEFT JOIN product ON ... LEFT JOIN department ON ... -- Best Regards, Tarlika Elisabeth Schmitz A: Because it breaks the logical

Re: [SQL] 3 SELECTs rolled into 1 ?

2008-06-04 Thread Tarlika Elisabeth Schmitz
On Wed, 4 Jun 2008 09:55:46 +0200 A. Kretschmer [EMAIL PROTECTED] wrote: am Wed, dem 04.06.2008, um 8:41:29 +0100 mailte Tarlika Elisabeth Schmitz folgendes: I have 3 similar SELECTs. I am wondering whether they could be rolled into one? SELECT item.id, department.id

[SQL] UPDATE with table join

2008-05-27 Thread Tarlika Elisabeth Schmitz
' AND ... ) Is this the most efficient way of doing this? Is there a limit to the number of results that IN can cope with? This needs to run on Postgres 7.4. -- Best Regards, Tarlika Elisabeth Schmitz A: Because it breaks the logical sequence of discussion Q: Why is top posting bad? -- Sent via pgsql-sql mailing