Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 86CD0125100 for ; Tue, 15 May 2012 05:06:33 -0300 (ADT) Received: from mail-gg0-f174.google.com ([209.85.161.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SUCm3-0006hb-Fg for pgsql-sql@postgresql.org; Tue, 15 May 2012 08:06:32 +0000 Received: by gglu4 with SMTP id u4so3941047ggl.19 for ; Tue, 15 May 2012 01:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=kFMt6JVRxg8sG+mgXj2nnkOEEag2s6lVZ2wz8R50lfE=; b=Beuyoyxh5yoMoherruSKS6xr4HfJdCqe2tkbEqepd682UwnFeKDE7FhfMuz6Vsq4JI dW6Xgx1dPLNpg793heF0AtShQdbNiv0ibkevEgcaeBo6kyasiGgE72eRm2ekZaot8pt5 rGTV/THuEg7rgPcD9+Vz5JdTakRSddn+rhd6ZZgibAzizqzssW1rNFFTkRhl+opD7jPN cF6qNiHBYbwwjr5ybVEf9ecWD9kGz6RkBlE75pbt3Pjzku4FLTz1LNLjNbWP+2aOA8bu uwJXYxJt3knw1RhOyLCXJ8uHJvNYRmJFWEjNAarXeHZgk3oM/7B+O+EkLN8L0zAxajwV CgOQ== Received: by 10.50.180.225 with SMTP id dr1mr6106942igc.52.1337069174363; Tue, 15 May 2012 01:06:14 -0700 (PDT) MIME-Version: 1.0 From: Misa Simic Date: Tue, 15 May 2012 01:06:14 -0700 Message-ID: <4455331181314515275@unknownmsgid> Subject: Re: SELECT 1st field To: Jan Bakuwel , "pgsql-sql@postgresql.org" Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201205/38 X-Sequence-Number: 36586 When you select from function I think column name is the same as function name. So if function name is func query would be: SELECT func AS id FROM func(5); Sent from my Windows Phone From: Jan Bakuwel Sent: 15/05/2012 08:02 To: pgsql-sql@postgresql.org Subject: [SQL] SELECT 1st field Hi, I've spend some time checking the documentation but haven't been able to find what I'm looking for. I've got a function that returns a set of integers and a view that selects from the function. What I need is the ability to name the column in the view, ie. create function func(i int) returns setof integer as $$ ... ...code ... $$ language plpythonu volatile; create view v as select 1 as "id" from func(5); In other words I'd like to refer to the first (and only) field returned and give that an alias, in this case "id". In some SQL dialects you can use "select 1" to select the first field, "select 2" to select the 2nd field and so on. Any suggestions? regards, Jan