Home > Blockchain >  Arrange the products in descending order of thier MFG_DATE. In case of same MFG_DATE arrange them in
Arrange the products in descending order of thier MFG_DATE. In case of same MFG_DATE arrange them in

Time:05-13

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)

CodePudding user response:

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;

dbfiddle

CodePudding user response:

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).

  • Related