oracle - SQL, return rows if there is no data in specified date -
have 2 tables in oracle db. 1 containing static data, info_table
, , other includes daily updated data, stats_table
. info_table
contains static data each wcel_id (coordinates etc..), , stats_table
being updated automatically everyday.
sometimes, possible no data wcel_id, in particular date, wcel_id may missing in stats_tabel. problem is, when query data week example, data days specified wcel_id has entry in stats_table
, want null
if there no data specific date. below query
select *
from stats_table full join info_table e
on a.wcel_id = e.wcel_id
where
a.period_start_time >= trunc(sysdate-7) , a.wcel_id = '14000004554984'
this return 1 row, since have no data a.wcel_id = '14000004554984'
6 days, want have 1 row + 6 rows nulls.
how can implement correct query?
thanks in advance...
move clause join criteria or add or and
and (a.wcel_id null or a.wcel_id = '14....')
select * stats_table full join info_table e on a.wcel_id = e.wcel_id , a.period_start_time >= trunc(sysdate-7) , a.wcel_id = '14000004554984'
Comments
Post a Comment