我有以下 oracle 查询:
SELECT distinct DM.name,
ND.param5 ,
ND.param4 ,
DECODE(ND.param3, 'TRS01','Mark for Return to warehouse',
'TRS02','Waiting for distributor approval on return',
'TRS03','Waiting for Service Provider approval on return',
'TRS04','Return to Distributor',
'TRS05','Return to Warehouse',
'TRS06','Mark for Return to Distributor',
'TRS08','Quarantined',
'TRS10' ,'New',
'TRS11','Waiting for Distributor acceptance',
'TRS12' ,'Moved to distributor warehouse',
'TRS13','Waiting for reseller acceptance',
'TRS14','Moved to reseller warehouse',
'TRS15','In-Use',
'TRS16','Returned',
'TRS17','Deattached',
'TRS18','Sold'), NS.name ,
COUNT( distinct ND.NUMBERDETAILID) serialcount,ND.param3,'ALL',
FROM ndetail ND,
nbatch NB,
nstatus NS,
dynamicmaster DM,(select his.createdate,h.numberdetailid,his.numberstatusid,his.param3,his.actualnumber
from ndetailhistory his,
(select max(createdate) createdate,numberdetailid
from ndetailhistory
group by numberdetailid) h
where h.numberdetailid = his.numberdetailid
and h.createdate = his.createdate) NDH
WHERE ND.numberbatchid = NB.numberbatchid
AND NS.numberstatusid = ND.numberstatusid
and DM.DYNAMICMASTERID = NB.WAREHOUSEID
and NDH.actualnumber = ND.actualnumber
and ND.NUMBERDETAILID = NDH.NUMBERDETAILID
and NB.numbergroupid = (select numbergroupid from ngroup where alias = 'TEST')
AND (case when 'ALL'='ALL' THEN '1' ELSE ND.PARAM3 END ) =(case when 'ALL'='ALL' THEN '1' ELSE 'ALL' END )
GROUP BY DM.name,ND.param5,ND.param4,ND.param3,NS.name
order by 1,3,2
我也想在选择列表中创建,但不想与 createdate 分组。
我怎样才能做到这一点?