Page 1 of 1

Selecting first record from a table

Posted: Mon Apr 26, 2010 1:19 am
by saj
Hi ,
I have a req where I need to select only the first record from a oracle table via Datastage job .Could any one tell me how to select only the first rec.

Posted: Mon Apr 26, 2010 1:52 am
by hamzaqk
there is no such thing as first record in the table.. you need to specify on what condition you need to pull the record

Posted: Mon Apr 26, 2010 1:54 am
by hamzaqk
there is no such thing as first record in the table.. you need to specify on what condition you need to pull the record

Posted: Mon Apr 26, 2010 6:07 am
by chulett
And then once you figure out what the 'first' record should be, either constrain your query to its primary key value or perhaps use "and rownum = 1" to help there.

Posted: Mon Apr 26, 2010 6:25 am
by ray.wurlod
It is a fundamental tenet of database design and usage that it is the database server, not the user, that determines order of storage. Therefore, unless every record is timestamped somehow with the date/time it was inserted (so that you can specify the oldest), there is no such thing as the first record in a table. I believe you need to re-think your requirement.

Posted: Mon Apr 26, 2010 6:26 am
by ray.wurlod
It's easy enough to select "only one" record from the table. For example you can constrain on ROWNUM = 1.