Skip site navigation (1) Skip section navigation (2)

Re: using ordinal_position

From: Igor Neyman <ineyman(at)perceptron(dot)com>
To: "johnf(at)jfcomputer(dot)com" <johnf(at)jfcomputer(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: using ordinal_position
Date: 2012-06-11 15:14:00
Message-ID: A76B25F2823E954C9E45E32FA49D70EC08E4070B@mail.corp.perceptron.com (view raw or flat)
Thread:
Lists: pgsql-sql

> -----Original Message-----
> From: John Fabiani [mailto:johnf(at)jfcomputer(dot)com]
> Sent: Monday, June 11, 2012 11:11 AM
> To: Igor Neyman
> Cc: pgsql-sql(at)postgresql(dot)org
> Subject: Re: using ordinal_position
> 
> On 06/11/2012 06:53 AM, Igor Neyman wrote:
> >
> >> -----Original Message-----
> >> From: John Fabiani [mailto:johnf(at)jfcomputer(dot)com]
> >> Sent: Thursday, June 07, 2012 7:18 PM
> >> To: pgsql-sql(at)postgresql(dot)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

Did you mean MySQL or MS SQL?  Because MS SQL Server does not allow ordinal position AFAIK.

Igor

In response to

pgsql-sql by date

Next:From: Wayne CuddyDate: 2012-06-13 00:05:45
Subject: Partitioned Tables
Previous:From: John FabianiDate: 2012-06-11 15:10:35
Subject: Re: using ordinal_position

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group