Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 14A3C19F3CF for ; Mon, 11 Jun 2012 12:11:02 -0300 (ADT) Received: from [76.14.161.106] (helo=newserver.jfcomputer.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Se6Gi-0005t7-Gh for pgsql-sql@postgresql.org; Mon, 11 Jun 2012 15:11:02 +0000 Received: from localhost (unknown [127.0.0.1]) by newserver.jfcomputer.com (Postfix) with ESMTP id 86C94FCF3; Mon, 11 Jun 2012 15:10:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at site Received: from newserver.jfcomputer.com ([127.0.0.1]) by localhost (linux-jfp8.site [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mYU+Jijn60KP; Mon, 11 Jun 2012 08:10:35 -0700 (PDT) Received: from [192.168.1.114] (unknown [192.168.1.254]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johnf@jfcomputer.com) by newserver.jfcomputer.com (Postfix) with ESMTPSA id D63F5555A; Mon, 11 Jun 2012 08:10:35 -0700 (PDT) Message-ID: <4FD60A6B.3090706@jfcomputer.com> Date: Mon, 11 Jun 2012 08:10:35 -0700 From: John Fabiani Reply-To: johnf@jfcomputer.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 MIME-Version: 1.0 To: Igor Neyman CC: "pgsql-sql@postgresql.org" Subject: Re: using ordinal_position References: <4FD1368E.5000304@jfcomputer.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 76.14.161.106 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201206/28 X-Sequence-Number: 36682 On 06/11/2012 06:53 AM, Igor Neyman wrote: > >> -----Original Message----- >> From: John Fabiani [mailto:johnf@jfcomputer.com] >> Sent: Thursday, June 07, 2012 7:18 PM >> To: pgsql-sql@postgresql.org >> Subject: using ordinal_position >> >> I'm attempting to retrieve data using a select statement without >> knowing the column names. I know the ordinal position but not the name >> of the column (happens to be a date::text and I have 13 fields). >> >> Below provides the name of the column in position 3: >> >> select column_name from (select column_name::text, ordinal_position >> from information_schema.columns where >> table_name='wk_test') as foo where ordinal_position = 3; >> >> But how can I use the above as a column name in a normal select >> statement. >> >> Unlike other databases I just can't use ordinal position in the select >> statement - RIGHT??? >> >> Johnf > David gave you already pretty complete answer. > I just wonder what are these "other" RDBMSs that allow to use ordinal column positions in a query? > I am familiar with a few (in addition to Postgress), and none of them does that, not in "select" list., though everybody allow ordinal position from "select" list in "order by" and "group by". > > Regards, > Igor Neyman > > > VFP uses position (you might not consider DBF a database). MsSQl (ordinal_position). Those are the only two I'm aware of. Johnf