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?

Answers were Sorted based on User's Feedback



I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / venkat ramana

SELECT PRODUCTNAME
FROM PRODUCT
WHERE COST < (SELECT MAX(COST)FROM PRODUCT)
ORDER BY COST DESC
FETCH FIRST 1 ROW ONLY ;

HOPE THE ABOVE QUERY WILL PROVIDE YOU THE DESIRED RESULT.

Is This Answer Correct ?    14 Yes 2 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / rajasekaran

with e as (select product_name,cost,rank() over(order by
cost desc) as rk from product) select * from e where rk=2;

Is This Answer Correct ?    3 Yes 0 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / 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

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / dinesh m

A)
select productname from product
where cost=(Select max(cost) from product where cost not in
(select max (cost) from product) );

Is This Answer Correct ?    0 Yes 0 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / pc

select productname from product where cost=(select max(cost) from product where cost<> (select max(cost) from product));

Is This Answer Correct ?    0 Yes 0 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / vineeth varghese

(Select product from product where cost = (Select Max (cost) from product where cost not = (select max (cost) from product)))

Is This Answer Correct ?    0 Yes 0 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / siri

select productname from product p where 2=(select count(*) from product q where p.cost<=q.cost)

Is This Answer Correct ?    0 Yes 1 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / mr. cooooool

Hi............

SELECT PRODUCTNAME FROM PRODUCT WHERE COST = (SELECT MAX(COST)
FROM PRODUCT WHERE COST > (SELECT MAX(COST) FROM PRODUCT));

THANKS
REGARDS
RAVINDRA BISHT

Is This Answer Correct ?    13 Yes 15 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / ananth

We can also use correlated subquery for this..

Select product from product a where 1 =
(select count(*) from product b where a.cost < b.cost);

Is This Answer Correct ?    0 Yes 3 No

I have a table(product),It contain fields(productname,cost). I want to retrieve the product name ,w..

Answer / pratap

A)Select product, Max (cost) from product where cost <
(select max (cost) from product);

Is This Answer Correct ?    7 Yes 13 No

Post New Answer

More DB2 Interview Questions

How does one remove entries from the SCT02 table?

1 Answers  


how does the defining of a stored procedure effect the size of a DB2 data base A) it increases the size of a data base B) it decreases the size of a data base C) it does not effect the size of the data base D) it changes the table space structures

2 Answers   Accenture,


what is copy pending and check pending ?

1 Answers   Xansa,


Which catalog table stores referential constraints?

1 Answers  


What information can you find in SYSIBM.SYSLINKS table?

1 Answers   TCS,






How to retrieve rows from a db2 table in embedded sql?

0 Answers  


How to fetch the last row from the table in SQL (db2)?

0 Answers  


Define predicate?

0 Answers  


How to solved 818 error

4 Answers   Keane India Ltd, Wipro,


In SPUFI suppose you want to select maximum of 1000 rows, but the select returns only 200 rows. What are the 2 SQLCODEs that are returned?

1 Answers  


Highlight all the advantages that are attached to a package.

0 Answers  


if there is a table with huge number of records and if i want to extract only first 3 records from the table, what query i have to provide to retreive first 3 records

4 Answers   UST,


Categories