I have a table(product),It contain fields(productname,cost).
I want to retrieve the product name ,which cost is second
maximum in the table?

Answer Posted / viki

SELECT PRODUCTNAME FROM PRODUCT WHERE COST <> max(COST)

AND PRODUCTNAME=

(SELECT PRODUCTNAME FROM PRODUCT WHERE COST =
(SELECT COST FROM PRODUCT
ORDER BY COST DESC
FETCH FIRST TWO ROWS ONLY))

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I add a column in db2?

674


What are bind parameters in db2?

693


How does a cursor work?

634


What is copy pending and check pending in db2?

666


How to get the ddl of a table in db2?

761






Is the primary key a clustered index?

726


Which isolation level provides highest data integrity?

675


What is iseries database?

673


How to access db2 tables in mainframe?

696


What is the difference between dbm cfg and db cfg file in db2 ?

1106


What is the function of logging in the db2 database?

730


What is coalesce in db2?

766


i tried to copy some records from microsoft excel to as-400 physical file through "Bosanova" emulation. Out of 14000 records only 12000 records copies and subsequently programe started to hang. Then, i closed the program forcefully. I did' under stand the problem. Also when i try to compile the physical file it is showing as "The file in use". How to overcome this problem?

2154


What is a trigger in the db2 database?

670


What is image copy in db2?

649