0
select (CURRENT_TIMESTAMP - '60 days'::interval);

This shows me a current time stamp with an interval of 60 days getting subtracted.

SELECT VALUE
    FROM schema_name.some_parameter
    WHERE some_parameter.NAME LIKE 'some_reference_name'

I want to add the above query in SELECT so that I don't need to add the hardcoded data for 60 days. I want to get it through the parameter variable.

Basically i need to use nested queries where the second query gets me the 60 days value i.e. hardcoded in first query.

Is there a possible solution for my problem?

champ.exe
  • 125
  • 16
  • @GHostGambler : Kindly check my doubt and then mark it as duplicate. It was not about declaring a query but merging two queries as one. – champ.exe Mar 06 '19 at 05:16

1 Answers1

1

Maybe something like this?

with v(val)
as
(
  VALUES(  CURRENT_TIMESTAMP - '60 days'::interval)
)
SELECT v.val  from
     schema_name.some_parameter cross join v
    WHERE some_parameter.NAME LIKE 'some_reference_name'
Kaushik Nayak
  • 30,772
  • 5
  • 32
  • 45
  • I do not want to use the hard coded data of 60 days. That is passed by the some_paramter file. – champ.exe Mar 05 '19 at 09:35
  • 1
    @Ankit : Ask a new question explaining clearly what you want, your description in the question is not clear. We can't read what's in your mind when you say "some_paramter file" etc? – Kaushik Nayak Mar 05 '19 at 09:44
  • In my first case I'm adding a hard coded value of 60 days which is already available in my parameter file. The second query has the 60 days parameter in it. I want to merge it with the first query and not use the hard coded 60 days mentioned in he first query. – champ.exe Mar 05 '19 at 09:47
  • Basically i need to use nested queries where the second query gets me the 60 days value i.e. hardcoded in first query. – champ.exe Mar 05 '19 at 10:08