Click here to Skip to main content
16,005,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an SQL assignment question that stumps me! I need help...

The question is as follows.

From a table called product that has fields such as product name, price, category description, find the second lowest unitprice in the product table and display the products name.

I've come up with the following code to get the second lowest unitprice but I need to do another nested query to return the product description.

Select min(UnitPrice)
From tblProduct
Where UnitPrice <> (Select min(UnitPrice) from tblProduct)

How do I do this????
Posted

 
Share this answer
 
hi samcro try this one

Select UnitPrice,description From tblProduct P1
Where 2=(Select Count(*) From tblProduct P2
Where P1.UnitPrice >= P2.UnitPrice)


if you want second largest then make <=

hope this will solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900