Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


quary for
1> fetch last record
2> fetch in reverse order
3> fetch last 5 row
4> fetch second last record (their is no primary key)
i think concept of count can be use for this in 4th

Answers were Sorted based on User's Feedback



quary for 1> fetch last record 2> fetch in reverse order 3> fetch last 5 row 4> fet..

Answer / sarath

1) select id,name from tab1 order by id desc fetch first
row only
2) select id,name from tab1 order by id desc
3) select id,name from tab1 order by id desc fetch first 5
rows only
4) select id,count(*),name from tab1 order by id where count
(*) = (select count(*) from tab1)-1

Is This Answer Correct ?    6 Yes 3 No

quary for 1> fetch last record 2> fetch in reverse order 3> fetch last 5 row 4> fet..

Answer / pavan

please try this one and let me know....


select * from emp where :ws-rec-cnt = (select Count(*)
into :ws-rec-cnt from emp);

Is This Answer Correct ?    3 Yes 2 No

quary for 1> fetch last record 2> fetch in reverse order 3> fetch last 5 row 4> fet..

Answer / pavan

the above one is for fetching last record and i think u can
decraese (use < symbol) the count and use it for fetching
nth record in a table.

Is This Answer Correct ?    2 Yes 1 No

quary for 1> fetch last record 2> fetch in reverse order 3> fetch last 5 row 4> fet..

Answer / sudipta

the 4th answer is(ignore the previous one)

db2=> with t1(a,b,c) as (select id,name,row_number()
over(order by id desc) as aa from tab1) select * from t1
where c=2

Is This Answer Correct ?    2 Yes 1 No

quary for 1> fetch last record 2> fetch in reverse order 3> fetch last 5 row 4> fet..

Answer / sudipta

u may try this
assuming table 'tab1' has 2 fields id & name
1) select id,name from tab1 order by id desc fetch first
row only
2) select id,name from tab1 order by id desc
3) select id,name from tab1 order by id desc fetch first 5
rows only
4) select id,count(*),name from tab1 order by id where count
(*)<(select count(*) from tab1)

u try these & if any problem u may write

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More DB2 Interview Questions

What are PACKAGES ?

3 Answers  


cursor with hold explain ?

1 Answers   Verizon,


Select empno, sal from emptbl where empno < 101.By this query can we fetch first 100 recs? where empno is primary key.It won't throw -811 error? if it wont,then what is use of cursor technique while fetching first 100 recs. Please need more clarification.

2 Answers  


How can tablespace be moved to another dasd volume that is allocated for that tablespace?

0 Answers  


How to design maps

1 Answers   Virtusa,


How can the duplicate values be eliminated from db2 select?

0 Answers  


what is the sqlcode -501

5 Answers   IBM, Polaris, Zeus,


What is db2 and what is the use of db2 optimizer?

0 Answers  


Mention data types used in db2 ?

0 Answers  


How will you delete duplicate records from a table?

7 Answers   Google,


Why might full image copies be faster to implement than an incremental image copy?

4 Answers  


How do you Load a table ?? and what is Load replace ?

2 Answers   Xansa,


Categories