K
K
Korifa2021-12-27 17:02:32
Oracle
Korifa, 2021-12-27 17:02:32

Aggregation in group and window function context?

How will this request work?
will the inner sum calculate the sum within buy groups if ins_date is equal to cur_date, and then the outer sum will sum up the result in the context of sections?

select      cur_date,
    field_1,
    field_2,
    field_3,
    field_4,
        sum(sum(case when ins_date = cur_date then val else 0 end))
        over(partition by 
              field_2,
              field_3,
              field_4 ) -- group by within company if field_1 -company
   from  table_1
 where  ins_date between add_months(cur_date, -2) and cur_date
 group  by 
    field_1,
    field_2,
    field_3,
    field_4,

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Akina, 2021-12-28
@Korifa

How will this request work?
will the inner sum calculate the sum within buy groups if ins_date is equal to cur_date, and then the outer sum sums the result in the context of sections?

That is exactly what will happen. Think of window functions as working after HAVING and before ORDER BY.

R
Ruslan Makarov, 2015-08-27
@muaythai075

30%
- keywords 30% - words "here", "here", etc.
30% - just links: " site.ru/statya.html "
Buy eternal, very smoothly, slowly, only on thematic sites with traffic from 400 PS :
Personal opinion

H
Hitmanp, 2015-08-31
@Hitmanp

If there is no experience in acquiring links, then we use the seopult https://seopult.ru/ref/c41d3db8960bf170
The system automatically predicts a plan for purchasing links. For a new site, connect SeoPult max. It will give links from verified donors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question