sql - Group function in select with subquery -
i have following select :
select distinct max(tctc_cntipcli) "typeofcontract" , max(texe_cncclipu) "contractnumber", max(tctc_cndocidc) "clientname", max(tsrv_cndesser) "servicename", max(texe_cnfuncid) "servicenumber", tsrs_cnsubsdc "subservicename", texe_cnsubser "subservicenumber", tmap_cndesc "map", ( select decode(to_char(count(tlof_cnlofrid)), '0', 'na', count(tlof_cnlofrid)) service.kndtlof tlof_cncclipu = tctc_cncclipu , tlof_cnservic = texe_cnfuncid , tlof_cnsubser = texe_cnsubser , tlof_cnfhalta > trunc (sysdate, 'mm') ) "volumeoffilesmessages" service.kndtctc, service.kndtexe, service.kndtscm, service.kndtsrv, service.kndtsrs, service.kndtmap tctc_cncclipu = texe_cncclipu , texe_cnfuncid = tsrv_cncveser , texe_cnfuncid = tsrs_cncveser , texe_cnsubser = tsrs_cnsubser , texe_cncclipu = tscm_cncontra , tscm_cnmapco = tmap_cnmapco , tscm_cnservic = tsrv_cncveser , tscm_cnsubser = tsrs_cnsubser , tctc_cnestado in ('01', '03') , texe_cnestado in ('01', '03') , tsrv_cnestado in ('01', '03') , tsrs_cnestado in ('01', '03') , tscm_cnestado in ('01', '03') , tmap_cnestado in ('01', '03') group tsrs_cnsubsdc, texe_cnsubser, tmap_cndesc order texe_cncclipu;
which outputting :
c|50000614|lindsey|informationreporting|3050|940previousday|i1|baisamedaywire|n c|50000614|lindsey|wirepayments|3001|wirestatus|s1|mt101swiftstatus|na c|50000614|lindsey|wirepayments|3001|wirepayments|w1|sungard820payment|na
i need use max on columns 1, 2, 3 , duplicating columns 4 , 5 make output below:
c|50000614|lindsey|informationrep|3050|previousday |i1|baisamedaywire |na wirepayments |3001|wirestatus |s1|mt101swiftstatus |na wirepayments|w1|sungard820payment|na
i have tried max on selected columns in outer query , keep getting "ora 0037 : not single-group group function" error. thanks.
max
analytic function. means computes single value based on set of rows. take @ this page documentation on function itself, , this page info on analytic functions. you're going have group data according spec using group by
statement, otherwise encounter error ora-00937, before.
Comments
Post a Comment