Re: [SQL] Subqueries

2008-10-31 Thread Gregory Stark
"Pascal Tufenkji" <[EMAIL PROTECTED]> writes: > I understand the fact that "the inner query is executed before the outer > query and the inner query doesn't even know about the outer query." > > But why the following query can be executed, although the inner query is > using the outer query. > >

Re: [SQL] Subqueries

2008-10-31 Thread Pascal Tufenkji
53 PM To: [EMAIL PROTECTED] Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Subqueries The "v" reference need to exist in the inner query. You can't use an "outer query reference" in the inner query. This happens because the inner query is executed before the outer query and

Re: [SQL] Subqueries

2008-10-30 Thread Helio Campos Mello de Andrade
The "v" reference need to exist in the inner query. You can't use an "outer query reference" in the inner query. This happens because the inner query is executed before the outer query and the inner query doesn't even know about the outer query. May be this helps you get what you want. SELECT *,

Re: [SQL] Subqueries

2008-10-30 Thread Oliveiros Cristina
alias v not visible in sub-query? - Original Message - From: Pascal Tufenkji To: pgsql-sql@postgresql.org Sent: Thursday, October 30, 2008 12:17 PM Subject: [SQL] Subqueries Hello, I don't understand the following error. Can anyone help me plz Thx Pascal

Re: [SQL] Subqueries returning more than one value?

2004-05-11 Thread CoL
hi, Adam Witney wrote, On 5/11/2004 02:09: Hi, I am using a function in a subquery, this works ok: SELECT name, (SELECT p_my_func(1)) AS id FROM test; However I would like to have the function return 2 values into the main query... Something like this: SELECT name, (SELECT p_my_func(1)) AS (id

Re: [SQL] Subqueries in select clause

2001-04-18 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Until you can upgrade, though, try this approach: > CREATE VIEW c_aggregate AS > SELECT sum(a) as sum_a, b FROM c GROUP BY b; > SELECT max(sum_a) FROM c_aggregate; Unfortunately that won't work in 7.0 --- grouped views have a lot of problems in that v

Re: [SQL] Subqueries in select clause

2001-04-18 Thread Josh Berkus
Sara, Hey! Great to see that Postgres has made it to Israel. What's the most popular Linux distribution there? I think you have your answer ... an upgrade. RPMs for most major distributions of Linux should be available within the week. Until you can upgrade, though, try this approach: CREA

Re: [SQL] Subqueries in select clause

2001-04-18 Thread Richard Huxton
Sara Cohen <[EMAIL PROTECTED]> said: > Hi, > > I am attempting to use subqueries in the select clause of a query > and am encountering difficulties. > > The Problem: > > > I would like to use a subquery that returns one column, but more than one > tuple. The result of this subquer

Re: [SQL] Subqueries in select clause

2001-04-18 Thread Stephan Szabo
On Wed, 18 Apr 2001, Sara Cohen wrote: > The Problem: > > > I would like to use a subquery that returns one column, but more than one > tuple. The result of this subquery is then used in an aggregate function. > > For example, suppose I have a table c, with columns a and b of > num

Re: [SQL] Subqueries in select clause

2001-04-18 Thread Tom Lane
Sara Cohen <[EMAIL PROTECTED]> writes: > Using Oracle, I could get by this problem with: > select max(d) from ((select count(b) as d from c group by a)); > However, my version of postgres doesn't support subqueries in the from > clause. Time to update to 7.1... rega

Re: [SQL] Subqueries in Non-SELECT Queries

2000-12-18 Thread Frank Joerdens
Christof Glaser wrote: [ . . . ] > since the where clause compares just one field for equality. You might > try IN instead of =, ie > > update index set level = 2 where parentid in ( select id from > index where level = 1 ); That was it! Thanks, Frank

Re: [SQL] Subqueries in Non-SELECT Queries

2000-12-17 Thread Tom Lane
Frank Joerdens <[EMAIL PROTECTED]> writes: > mpi=# update index set level = 2 where parentid = ( select id from > index where level = 1 ); > ERROR: More than one tuple returned by a subselect used as an expression. Apparently the subquery "select id from index where level = 1" is returning more

Re: [SQL] Subqueries in Non-SELECT Queries

2000-12-17 Thread Christof Glaser
Frank Joerdens wrote: > mpi=# update index set level = 2 where parentid = ( select id from > index where level = 1 ); > ERROR: More than one tuple returned by a subselect used as an > expression. mpi=# > > This is a recursive query, on a single table. Is that not possible? Hi Frank, as the err

RE: [SQL] subqueries as values in updates

2000-12-08 Thread Francis Solomon
Hi, The syntax you used works fine for me. francis=# select version(); version --- PostgreSQL 7.0.2 on i686-pc-linux-gnu, compiled by gcc 2.95.2 (1 row) Hope this helps Francis Solomon > -Original Mes

Re: [SQL] Subqueries in from clause

2000-11-03 Thread Tom Lane
Pierre Habraken <[EMAIL PROTECTED]> writes: > It looks like if subqueries in from clause are not supported by > PostgreSQL. Am I right ? If yes, are there any plans to provide this > feature soon ? Already there in current sources for 7.1 ... regards, tom lane

Re: [SQL] Subqueries in from clause?

2000-09-25 Thread Tom Lane
Meszaros Attila <[EMAIL PROTECTED]> writes: > How far is the above subject from beeing implemented? I'm looking at it right now ... no promises yet, though. regards, tom lane