sql - How do i divide by an Alias? -


when run follwing query ora- 00937 error.

select apex_utilities.get_invtype(o_code) ,count(c.id) "case count" ,round(sum(billable_time/3600),2) "time(hrs)" ,round(sum(billable_time/count(c.id)),2) "aht(secs)"        mytable c c.date_created between :p31_period_start , add_months(:p31_period_start,1) group rollup(apex_utilities.get_invtype(o_code)); 

if comment out line

    ,round(sum(billable_time/count(c.id)),2) "aht(secs)" 

it runs expected, without column appearing.

how run including line? if add billable_time group output incorrect many rows groups billable_time invtype. in addition have remove 'sum' line run.

the output looking similar following

invtype    casecount    time(hrs)    aht(secs) cdcw          1234       308:53:45   909.56 cbcb          100        24:56:34    109.24 

it seems want actually:

 ,round(sum(billable_time)/count(c.id),2) "aht(secs)"`  

i suspect it's balking because aggregating inside aggregation. if mean this, you'll need subquery count(c.id) can apply inside aggregation of sum(billable_time, count_of_c_id) bit.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -