Re: [SQL] "Subquery must return only one column" & query optimization

2008-12-15 Thread Philippe Lang
pgsql-sql-ow...@postgresql.org wrote: > "Philippe Lang" writes: >> I was trying to run this query this morning: > >> -- >> SELECT > >> r.*, > >> ( >> SELECT > >> rl.reminder_header, >> rl.reminder_footer > >> FROM reminder_levels AS rl >> WHERE

Re: [SQL] "Subquery must return only one column" & query optimization

2008-12-15 Thread Tom Lane
"Philippe Lang" writes: > I was trying to run this query this morning: > -- > SELECT > r.*, > ( > SELECT > rl.reminder_header, > rl.reminder_footer > FROM reminder_levels AS rl > WHERE rl.lookup = > ( > SELECT MAX(rem

[SQL] "Subquery must return only one column" & query optimization

2008-12-15 Thread Philippe Lang
Hi, I was trying to run this query this morning: -- SELECT r.*, ( SELECT rl.reminder_header, rl.reminder_footer FROM reminder_levels AS rl WHERE rl.lookup = ( SELECT MAX(reminder_level_lookup)

[SQL] create table with rownames as values in column of seciond table

2008-12-15 Thread Marco Lechner
Hi list, I try to create a table using plpgsql or plpythonu. I'm starting with programming in postgresql therfore I'm a little bit confused. I know a little bit of python and a little bit of SQL. May be some hints could help me gettin into it: My problem is: I'm having a table with a column a and

Re: [SQL] create table with rownames as values in column of seciond table

2008-12-15 Thread George Pavlov
your problem is a little unorthodox, but i will spare you the "why the heck do you want to do this?" discussion and assume you have good reasons... so here's a "dynamic SQL" approach: select 'create table test (id bigint, '|| array_to_string(array(select a||' text' from foo),', ')||');'; not pret