![Confused :?](./images/smilies/icon_confused.gif)
how we delete 3rd row from one table
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 1
- Joined: Wed Aug 10, 2011 11:42 am
how we delete 3rd row from one table
please let me know the answer thanks in advance ![Confused :?](./images/smilies/icon_confused.gif)
![Confused :?](./images/smilies/icon_confused.gif)
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
chulett wrote:Technically, your first question is irrelevant.
My guess is, if it's sql server database and there's a identity column(which is in sequence) , then we can make use of the below query:
Code: Select all
DELETE FROM table_name WHERE IDENTITY_COLUMN=3
Thanks
pandeeswaran
Still, doesn't matter. Having an "identity column" (or any other surrogate value) with a 3 in it doesn't make it "the third row". It's not sequential media, after all.
That's not to say that based on very specific conditions and/or sort orders, you couldn't identify the third record in the result set. But in the table? No such thing. Like I said, a trick question. And they've already specified it is an Oracle database.
That's not to say that based on very specific conditions and/or sort orders, you couldn't identify the third record in the result set. But in the table? No such thing. Like I said, a trick question. And they've already specified it is an Oracle database.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There's no such thing, for a user, as the third row in a table. The mechanism by which rows are stored in a table, are entirely the province of the database server.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
Third row in a table as such doesn't mean anything, however a question should be asked back like, on what basis you identify which is the third row. like based on date or some other sort key.. then rank() function comes in handy to get the third row.
But still there is no answer to the question asked in first post as it is.
But still there is no answer to the question asked in first post as it is.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
-
- Premium Member
- Posts: 353
- Joined: Mon Jan 17, 2011 5:03 am
- Location: Mumbai, India
Let KEY_1 is ur PK(or any distinct column) and ABCD is your table,
then this might help
delete from ABCD where key_1 in
(select key_1 from (
select key_1 from ABCD
fetch first 3 rows only)
order by 1 desc
fetch first row only)
@everybody
For every Question there's an answer.![Razz :P](./images/smilies/icon_razz.gif)
then this might help
delete from ABCD where key_1 in
(select key_1 from (
select key_1 from ABCD
fetch first 3 rows only)
order by 1 desc
fetch first row only)
@everybody
For every Question there's an answer.
![Razz :P](./images/smilies/icon_razz.gif)
Thanx and Regards,
ETL User
ETL User
-
- Premium Member
- Posts: 353
- Joined: Mon Jan 17, 2011 5:03 am
- Location: Mumbai, India
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI