I have a table named PARAMETER looking like this:
ID - number
NAME - varchar2
VALUE - varchar2
I have this query witch is 'extracting' the date from the string:
SELECT * from PARAMETER
where (NAME = 'From') and SUBSTR(VALUE, 1, 2)>='01'
and SUBSTR(ALUE, -7, 5)>='11' and SUBSTR(VALUE, -4, 4) >='2012'
Now I need to run it again changing only: where (NAME = 'From')
to where (NAME = 'To')
and compare the results. I can't find a way to do this. Is there a trick?
Select * From Parameter
Where Name='From'
AND TO_DATE(VALUE, 'DD/MM/YYYY') >= TO_DATE('01/11/2012', 'DD/MM/YYYY')
AND TO_DATE(VALUE, 'DD/MM/YYYY') <= TO_DATE('20/11/2012', 'DD/MM/YYYY')
UNION
Select * From Parameter
Where Name='To'
AND TO_DATE(VALUE, 'DD/MM/YYYY') >= TO_DATE('01/11/2012', 'DD/MM/YYYY')
AND TO_DATE(VALUE, 'DD/MM/YYYY') <= TO_DATE('20/11/2012', 'DD/MM/YYYY')
This will give you all dates that start from 01/11/2012 until 20/11/2012 AND all the dates that end in that period as well. I dont know if thats what you ask for.