Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Script with Constant

Status
Not open for further replies.

saw15

Technical User
Jan 24, 2001
468
US
Working with a select statement, I only want to pull the last 2 years data. So in the where clause I currently use:

where insert_datetime >= trunc(sysdate - 730).

I would like to know.. if you can set a constant variable of CalcDate where CalcDate = trunc(sysdate - 730) and just reference this declared variable within the where clause. Example... where insert_datetime >= CalcDate etc.

Help is appreciated.

Thanks
 
I am actually looking for an example of how its done, or the keyword used to define the variable etc if you have one.

Or any pointers in the right direction.
 
CalcDate date := trunc(sysdate-730);

or

CalcDate date;

in DECLARE section and ClacDate := trunc(sysdate-730) after BEGIN.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top