'Arrange the products in descending order of thier MFG_DATE. In case of same MFG_DATE arrange them in descending order of their PRICE
Can some one please tell me the correct way to write a SQL statement for the above Question.
I am doing this, but it shows Sql command not properly ended. I am using SQL *PLUS.
PRODUCT is the table name.
SELECT PROD_NAME FROM PRODUCT ORDER BY MFG_DATE DESC
(SELECT PROD_NAME FROM PRODUCT GROUP BY PRICE HAVING
COUNT(MFG_DATE)>1
ORDER BY
MFG_DATE DESC)
Solution 1:[1]
If I get it right, all you need to do is to specify the "price" column on the second place in the order by part:
select *
from product
order by mfg_date desc, price desc;
Solution 2:[2]
The way you explained it in the title, that would be
select prod_name
from product
order by mfg_date, price desc
(BTW, this is Oracle; SQL*Plus is its command-line tool).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ekochergin |
| Solution 2 | Littlefoot |
