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?

1
  • @GHostGambler : Kindly check my doubt and then mark it as duplicate. It was not about declaring a query but merging two queries as one. Commented Mar 6, 2019 at 5:16

1 Answer 1

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'
Sign up to request clarification or add additional context in comments.

4 Comments

I do not want to use the hard coded data of 60 days. That is passed by the some_paramter file.
@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?
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.
Basically i need to use nested queries where the second query gets me the 60 days value i.e. hardcoded in first query.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.