pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Fabiani <johnf@jfcomputer.com>
To: Igor Neyman <ineyman@perceptron.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: using ordinal_position
Date: Mon, 11 Jun 2012 08:10:35 -0700
Message-ID: <4FD60A6B.3090706@jfcomputer.com> (raw)
In-Reply-To: <A76B25F2823E954C9E45E32FA49D70EC08E406A7@mail.corp.perceptron.com>
References: <4FD1368E.5000304@jfcomputer.com>
	<A76B25F2823E954C9E45E32FA49D70EC08E406A7@mail.corp.perceptron.com>

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



view thread (5+ messages)  latest in thread

Message-ID: <4FD60A6B.3090706@jfcomputer.com>
Permalink:  ../4FD60A6B.3090706@jfcomputer.com/
Also on:    postgresql.org/message-id/4FD60A6B.3090706@jfcomputer.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: johnf@jfcomputer.com, ineyman@perceptron.com
  Subject: Re: using ordinal_position
  In-Reply-To: <4FD60A6B.3090706@jfcomputer.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox