i have a table like this :
Name ADDRESS
Toto 123 ...
Toto 456
ToTo 678

I would like to delete 2 last row...please tell me how to
delete its

Answers were Sorted based on User's Feedback



i have a table like this : Name ADDRESS Toto 123 ... Toto 456 ToTo 678 I..

Answer / mithlesh

delete from table_name
where address = '456' and '678'.

Is This Answer Correct ?    10 Yes 4 No

i have a table like this : Name ADDRESS Toto 123 ... Toto 456 ToTo 678 I..

Answer / siri

DELETE FROM TABLE WHERE ADDRESS IN('456','678')

Is This Answer Correct ?    2 Yes 0 No

i have a table like this : Name ADDRESS Toto 123 ... Toto 456 ToTo 678 I..

Answer / prashant shettar

delete from (select rownumber() over() as rowid from tab1 )
where rowid = ( (select count(*) from tab1) - 1)

Is This Answer Correct ?    2 Yes 1 No

i have a table like this : Name ADDRESS Toto 123 ... Toto 456 ToTo 678 I..

Answer / suv

We can use concept of cursor to delete particular row. The
row where the cursor is pointing will get deleted.

Please correct is wrong..

Is This Answer Correct ?    0 Yes 1 No

i have a table like this : Name ADDRESS Toto 123 ... Toto 456 ToTo 678 I..

Answer / vaneesh khurana

I think better to perform this in following 2 queries

1. Select count(WS-COUNT) from TABLE;

2. DELETE FROM TABLE WHERE ROWCOUNT(*) IS WS-COUNT OR
(WS-COUNT-1);

Basically here the first row will give you the record count
and 2nd will delete the last and the 2nd last row.

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More DB2 Interview Questions

How do you pull up a query which was previously saved in qmf?

0 Answers  


A Table feild is declared as Decimal(7,2). I want to insert the decimal in to this column thru cobol-db2 program. How should I declare my local input file variable or any suggestion?

7 Answers   IBM,


1) I have 3 programs : PGMA, PGMB, PGMC. PGMA calls PGMB and PGMB calls PGMC. I have to do inserts, updates in all the 3 pgms. 2) Say PGMC has done its work successfully and returned to PGMB 3) PGMB had an SQL error while doing some update 4) PGMA has already done some updates before calling PGMB all are running under the same CICS region. What will happen if I issue SYNCPOINT ROLLBACK in PGMB when it abends ? Does all the changes in PGMA,B,C rollback ? (because all the pgms belong to same task).

1 Answers  


How to resolve -502 sql code in DB2?

2 Answers   Cap Gemini,


How does cobol compile db2 program?

0 Answers  






Hi i need to write a query on the following requirement. SELECT COMM_TEXT INTO :WS_MIKM_COMM_TEXT FROM MPIPROD.MIKMV01 WHERE ACCOUNT_NO = :WFD_ACCOUNT_NO AND (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC) OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT) The above query is to be modified. The requirement is if both the fields are equal then that has to be given priority. In the above query if it satisfies any one it comes out without checking if both being equal is possible.

1 Answers  


SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD CHAR, TOKEN KEY was expected

0 Answers  


Q4. How will you get the count of record without using COUNT verb in query?

2 Answers   IBM,


What can the SET option of the Repair Utility accomplish?

1 Answers  


How to find the number of rows in db2 tables?

0 Answers  


what is the difference between where clause and having clause

2 Answers   IBM,


Why use RUNSTAT Utility?

3 Answers   Merrill Lynch,


Categories