Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
XavierC2
Frequent Visitor

Sql Query with Slicer Dates with or conditions

Hello,

here a sample of a query

 

 

select j2.no_seq_activite, j2.alias_ress,
j2.dh_debut as dh_debut,
nvl(j.dh_fin,j2.dh_fin) as dh_fin,
j.code_activite, j.desc_activite, substr(trim(replace(j2.remarque,'En rdpl vers le pt:')),1,6) as ptserv, j.desc_statut,
j2.code_activite, j2.desc_activite,
j2.dh_debut as debut_redepl, j2.dh_fin as fin_redepl, j.dh_debut as debut_1012, j.dh_fin as fin_1012, j2.remarque
from ra_journal_activite_his j, ra_journal_activite_his j2
where
(
(j.dh_debut between to_date('2021-04-01 00:00','yyyy-mm-dd hh24:mi') and to_date('2022-03-31 23:59:59','yyyy-mm-dd hh24:mi:ss')
or j.dh_fin between to_date('2021-04-01 00:00','yyyy-mm-dd hh24:mi') and to_date('2022-03-31 23:59:59','yyyy-mm-dd hh24:mi:ss'))
or
(j2.dh_debut between to_date('2021-04-01 00:00','yyyy-mm-dd hh24:mi') and to_date('2022-03-31 23:59:59','yyyy-mm-dd hh24:mi:ss')
or j2.dh_fin between to_date('2021-04-01 00:00','yyyy-mm-dd hh24:mi') and to_date('2022-03-31 23:59:59','yyyy-mm-dd hh24:mi:ss')))
and 
j2.code_activite = 'REDEPL'
and j2.alias_ress in ('53-R','53-J','53-N', '54-J', '54-S', '54-N', '55-J', '55-S', '55-N', '55-R')
and j.code_activite(+) like '10-12%'
and j.id_ress(+)=j2.id_ress and j.no_seq_activite(+)=j2.no_seq_activite+1
and substr(trim(replace(j2.remarque,'En rdpl vers le pt:')),1,6) in ('110-01', '110-02', '110-03', '110-22', '110-23', '107-01', '111-01', '111-03')

 

 

I need dates to be dynamic, I mean define by a slicer.
I don't find any solution to deal with the Or conditions. Paramaters are not an option because I need to use the query in an app on powerBI service.

Does anybody has an idea how I can deal with this?

thank you very much and have a good day.

2 REPLIES 2
smpa01
Super User
Super User

SQL relates to which RDBMS?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01 Oracle

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors