M
M
marselabdullin2020-10-28 12:00:54
Oracle
marselabdullin, 2020-10-28 12:00:54

How to insert a fraction in partition by?

I need to calculate the average value according to this formula:

sum(rashody)/count(distinct data_prikaza_)

And then this field including others is grouped in partition by, however I get an error:

not a single group group function

I used avg before and everything was fine, but now it does not fit
Perhaps it is worth checking for 0 denominator

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2020-10-29
@marselabdullin


select sum(rashody)/count(distinct data_prikaza_) over(partition by gosb) from erp_trips


count is not an analytic function, resulting in an ORA-00937 not a single-group function error . To fix the error, you need to add group by to the query .
Yes, and the request is, to put it mildly, strange. What information can be found by dividing the costs by the date of the order? Why is distinct needed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question