Is it possible to select periods from a table in a select without subquery?

Asked

Viewed 40 times

0

Greetings,

I wonder if it is possible to select a table period without using a subquery as an example below:

Select Usuario, Divida.Janeiro , Divida.Fevereiro, Divida.Marco ... from Usuarios a
left join VW_Dividas_Por_Mes b on a.cod_user = b.cod_user

In this case I have a view that brings results by date where dt_divida between '01/01/2020' and '31/01/2020' but I wanted to display only one month to month in select, without having to perform a subquery or specify the date in Join.

That’s possible?

  • What is "view" like? It column ?

  • The view would be: cod_user, dt_divide, value

  • You could make a case , something like sum(case when to_char(dt_divida,'yyyymm') = '202001' then value Else 0 end) ..., but I think the cost will be worse.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.