select created_date,count(*) tot
from smart_meters_t
group by created_date
order by created_date;
This code I want in Oracle Langauage.Please anyone help on this will be greatly helpful.
created_date tot
12/01/2019 148
06/02/2019 1
28/02/2019 48
I need data like below
created_date tot
12/01/2019 148
13/01/2019 148
14/01/2019 148
.
.
.
.
05/01/2019 148
06/02/2019 1
07/02/2019 1
08/02/2019 1
09/02/2019 1
.
.
.
.
27/02/2019 1
28/02/2019 48
You can generate a series of dates using:
select date '2019-01-02' + level
from dual
connect by date '2019-01-01' + level < date '2019-02-28'
Then the rest could be done with left join
and lag()
:
with dates as (
select (date '2019-01-02' + level) as dte
from dual
connect by date '2019-01-01' + level < date '2019-02-28'
)
select d.dte,
coalesce(t.tot,
lag(t.tot ignore nulls) over (order by d.dte)
) as tot
from dates d left join
t
on d.dte = t.created_date
order by d.dte;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.