Re: [SQL] SELECT max(time) group by problem

2009-07-30 Thread nha
e query would look like the following: SELECT MAX(timest) FROM table WHERE id IN (1,2,3) GROUP BY id; Q2) On the other hand, the 2nd query seems to take advantage of "table" index on its primay key (id,timest) as the 2 columns are explicitely referred in WHERE clauses. The sub-select would

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) =

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

2009-07-29 Thread nha
table and the SELECT expression in the WHERE clause; table1 is called (in fact, a copy of this table is implied) but no column of this table is bound to one or more of the current updated table1. I may mistake... Regards. -- nha / Lyon / France. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

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

2009-07-28 Thread nha
gt; AND t1.id <> t3.id > > AND h.id IS NOT NULL); > Beyond the solution brought by Daryl Richter, it seems that "h" is an unbound alias in the original (and also in the suggested) query. Some clarification would be help

Re: [SQL] Need magical advice for counting NOTHING

2009-07-24 Thread nha
ed that user_id and log_type_id are respectively keys for users and log_type tables, it is semantically admitted here that user_name identifies user_id in users table and log_type identifies log_type_id in log_type table. Regards. -- nha / Lyon / France. -- Sent via pgsql-sql mailing list (pgsql

Re: [SQL] using count in other column

2009-07-24 Thread nha
Hello again, Le 25/07/09 0:41, nha a écrit : > Hello, > > Le 23/07/09 11:59, bartjoosen a écrit : >> Hi, >> >> I made up a query to make a count for each item for each month/year: >> SELECT"Artnr_ID", to_char("Date_plan","&q

Re: [SQL] using count in other column

2009-07-24 Thread nha
hanks > > Bart > The error message you meet is missing in your report although it could surely help in accurate analysis. However I guess it is about using alias (like "Monthly_count") for defining project columns (like the one you tried and failed). Alias columns are used to rena

Re: [SQL] how to tell if column set on update

2009-07-22 Thread nha
nnot do that. You can only detect that a value has changed. > There would be one way to detect a value change but it is more related to application management than to data manipulation. For the column c2, it could be assumed that a flag is set when (a row of) c2 is updated. Such a flag m

Re: [SQL] Double aggregate problem

2009-07-22 Thread nha
plicity of value s.name and/or p.name may result depending on the keys of tables (as implicitly mentioned by Peter Eisentraut). Regards. -- nha / Lyon / France. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Double aggregate problem

2009-07-22 Thread nha
issued from the original one. WHERE and SORT clauses have been pulled off so that subqueries are not too enough broken down. Other optimization may be applied (eg. by using explicit joins between the different tables and by checking appropriate indexes are set up). Regards. -- nha / Lyon / France. -

Re: [SQL] Storing/sorting hex data in PostgreSQL

2009-07-21 Thread nha
unctions may be user-created. The sorting speed may then depend on the meaning of integer values (numeric relation relevance) with your data. Regards. -- nha / Lyon / France. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] unused columns in copy

2009-07-20 Thread nha
ay be performed (see also documentation of PostgreSQL 8.4): http://www.postgresql.org/docs/8.4/interactive/sql-copy.html Assuming that a CSV file contains data with column headers c1, c2, and c3, the following statement would retrieve only columns c1 and c2 from this file to a table t1: COPY t1(c1

Re: [SQL] how to tell if column set on update

2009-07-20 Thread nha
e, each column of the target table may be tested with their respective new and old values as well. Regards. -- nha / Lyon / France. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Recording how a table is used

2009-07-08 Thread nha
Hello, Le 8/07/09 11:30, nha a écrit : > Hello, > > Le 30/06/09 8:47, Daniel Gordon a écrit : >> I'm trying to record the results of a select statement into a separate >> table. I need the information selected, the column it was stored in, >> the table it w

Re: [SQL] Recording how a table is used

2009-07-08 Thread nha
s your purpose while both query and objects (tables and columns) are directly known and can be handled for a log query. Hoping these ideas help you go on investigating. Regards. -- nha / Lyon / France. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Create custom aggregate function and custom sfunc

2009-07-02 Thread nha
s many others for the current customer. This "edge effect" may be avoided in many ways depending on the original purpose. Regards. -- nha / Lyon / France. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql