Declare, Set, and Use a variable in a SQL Developer Query
748464Jan 22 2010 — edited Jan 25 2010I come from the SQL Server world and am trying to do something very simple: Declare, set, and use a variable in a query. For example:
Declare @lastPeriod date;
Set @lastPeriod = (select max(payperiod) from table 1 where payperiod < current_date);
Select field 1,
Field2
From table2
Where payperiod = @lastPeriod
The variable is going to be used in more areas in the query which is why I am simply not using a Sub-query in the where clause. I appreciate any assistance.