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] Select and merge rows?

2011-05-05 Thread Claudio Adriano Guarracino
Hello! I have a doubt about a query that I tried to do, but I cant.. This is the scenario: I have a table, with this rows: order    ID    value    -- 1    1000    3 2    1000    5 3    1000    6 1    1001    1 2    1001    2 1    1002    4 2    1002    4 I need to get

Re: [SQL] Select and merge rows?

2011-05-05 Thread Oliveiros
Howdy! Is there a maximum ceilling of three values per order ID? or an ID can have an arbitrary number of values? Best, Oliveiros 2011/5/5 Claudio Adriano Guarracino elni...@yahoo.com Hello! I have a doubt about a query that I tried to do, but I cant.. This is the scenario: I have a

[SQL] Select and merge rows?

2011-05-05 Thread Claudio Adriano Guarracino
Excuse me, The original table is: order    ID    value    -- 1    1000    3 2    1000    5 3    1000    6 1    1001    1 2    1001    2 1    1002    4 2    1002    4 The result of table should be: id    value1    value2    value3

[SQL] Re: [SQL] Select and merge rows?

2011-05-05 Thread Charlie
While there is insufficient information provided (a couple of table snippets), you may consider and experiment with the snippet below to get you started. SELECT ids.id, f1.value AS value1, f2.value AS value2, f3.value AS value3 FROM ( SELECT DISTINCT id FROM foo ) AS ids LEFT JOIN foo

[SQL] slightly OT - Using psql from Emacs with sql.el

2011-05-05 Thread Seb
Hi, When working with psql via sql.el, multiple prompts accumulate in a single line when sending multi-line input to the SQLi buffer. For example, sending the following: SELECT a, b, c, FROM some_table; with 'C-c C-r' results in these lines in the SQLi buffer: database_name=#

Re: [SQL] slightly OT - Using psql from Emacs with sql.el

2011-05-05 Thread Rob Sargent
On 05/05/2011 04:01 PM, Seb wrote: Hi, When working with psql via sql.el, multiple prompts accumulate in a single line when sending multi-line input to the SQLi buffer. For example, sending the following: SELECT a, b, c, FROM some_table; with 'C-c C-r' results in these lines in

Re: [SQL] slightly OT - Using psql from Emacs with sql.el

2011-05-05 Thread Seb
On Thu, 05 May 2011 16:47:09 -0600, Rob Sargent robjsarg...@gmail.com wrote: [...] Doesn't appear to. I use sql-mode alot/daily. The multiple prompts never bothers me, though the output not starting at the left kind of does. I've adapted someone's suggestion at the Emacs Wiki for that:

Re: [SQL] slightly OT - Using psql from Emacs with sql.el

2011-05-05 Thread Rob Sargent
On 05/05/2011 04:55 PM, Seb wrote: On Thu, 05 May 2011 16:47:09 -0600, Rob Sargentrobjsarg...@gmail.com wrote: [...] Doesn't appear to. I use sql-mode alot/daily. The multiple prompts never bothers me, though the output not starting at the left kind of does. I've adapted someone's

Re: [SQL] Select and merge rows?

2011-05-05 Thread Claudio Adriano Guarracino
Thank you very much! Your example help me a lot! The original query is more complex, but I can continue with this example. Thanks again! --- On Thu, 5/5/11, scorpda...@hotmail.com scorpda...@hotmail.com wrote: From: scorpda...@hotmail.com scorpda...@hotmail.com Subject: Re: [SQL] Select and

[SQL] check constraint bug?

2011-05-05 Thread Tarlika Elisabeth Schmitz
I specified: ALTER TABLE h ADD CONSTRAINT val_h_stats CHECK (NOT (sex = 'f') AND (stats IS NOT NULL)); which was translated to: ALTER TABLE h ADD CONSTRAINT val_h_stats CHECK (NOT sex = 'f'::bpchar AND stats IS NOT NULL); Can the expression not be bracketed? I changed this to: ALTER TABLE

Re: [SQL] Select and merge rows?

2011-05-05 Thread Claudio Adriano Guarracino
Hi again: I can did the same with crosstab: SELECT * FROM crosstab ( 'select id, order, value from test ORDER BY 1', 'select distinct order from test ORDER BY 1' ) AS (     id numeric(20),     value1 text,     value2 text,     value3 text );