mercredi 12 décembre 2018

Execute variation of query based on IF statement

Try to explain this simply below.

A simple if statement (in reality will be like

if sysdate >= trunc(sysdate)+5/24

), set up parameters to be used in the query

if 2>=1 then
  define ThisTime = trunc(sysdate)-1
else
  define ThisTime = trunc(sysdate)

select *
from table
where time >= &ThisTime

The above doesn't work and I'm wondering if it is possible? Unfortunately its a static monitoring query that runs from sqltoolkit in itrs and I can't think of another way of choosing a rollover time.

Aucun commentaire:

Enregistrer un commentaire