I\'ve the below result
VendorName | IncidentID | IncidentStatus | IncidentDate
-------------------------------------------------------
XYZ | 100 |
Use analytic functions:
SELECT *
FROM(
SELECT
VendorName,
IncidentID,
IncidentStatus,
IncidentDate,
MAX(IncidentDate) OVER (PARTITION BY VendorName) maxDate
FROM yourTable
) t
ORDER BY t.maxDate DESC, t.VendorName ASC, t.IncidentDate DESC
Refer to: http://docs.oracle.com/javadb/10.8.2.2/ref/rrefsqlj13658.html http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions003.htm http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions004.htm
This will do it ...
ORDER BY MAX(INCIDENTDATE) OVER (PARTITION BY VENDORNAME) DESC, INCIDENTDATE DESC
... but I'm not sure if the analytic function is allowed in the ORDER BY. If it isn't, calculate it in a subquery and order by in the main query ...
select ...
from (
select Max(incidentdate) over (partition by vendorname) max_incidentdate_by_vendor,
...)
order by max_incidentdate_by_vender desc, incidentdate desc
If you are on a RAC installation
set linesize 300
column REDOLOG_FILE_NAME format a50
SELECT
a.INST_ID,
a.GROUP#,
a.THREAD#,
a.SEQUENCE#,
a.ARCHIVED,
a.STATUS,
b.MEMBER AS REDOLOG_FILE_NAME,
(a.BYTES/1024/1024/1024) AS SIZE_GB
FROM gv$log a
JOIN gv$logfile b ON a.Group#=b.Group#
AND a.INST_ID=b.INST_ID
ORDER BY a.INST_ID ASC, a.GROUP# ASC;
select vendorname, incidentid, incidentstatus, incidentdate, max(incidentdate)
over (partition by vendorname order by incidentdate desc) max_incidentdate
from t1 order by max_incidentdate desc, incidentdate desc