Hi
Write a script that creates a cursor for a result set that consists of the ProductName and ListPrice columns for each product with a list price that's greater than $700. The rows in this result set should be sorted in descending sequence by list price. Then, the script should print the product name and list price for each product so it looks something like this:
Gibson SG, $2517.00
Gibson Les Paul, $1199.00
Thank you


Sunny SharmaRank #223 · 11.1K reputationPosted Oct 14, 2013, 9:44 PM EDT
Here you go:
----------------------------------------------
PRODUCTS is the name of the referenced table.
Cheers !!
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 14, 2013, 9:56 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Oct 14, 2013, 9:57 PM EDT
I think this can be achieved with out cursor.... as u know cursor is costly in term of memory consumption..
like
SELECT ProductName + ' $' + Cast(ListPrice AS VARCHAR(20)) AS Result FROM PRODUCTS WHERE ListPrice>700 ORDER BY ListPrice DESC
hope this will help you.
SUNIL GUTTARank #1,832 · 810 reputationPosted Oct 14, 2013, 10:10 PM EDT