Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have data for multiple Reporting years in my oracle table year_sales, I need to load data for only latest year. I am trying below script, however, not sure data is not getting loaded in Final table. Please guide me, I am not able to identify if I have made any silly mistake.
File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "Year_sales" ;
TEMP:
LOAD
Max(RPT_YEAR) as Current_Year
Resident File_status;
LET v_max_year = floor(peek('Current_Year'));
Final:
Load *
Resident File_status
where RPT_YEAR = $(v_max_year);
Drop Table TEMP;
Drop Table File_status;
Thanks in advance.
Regards,
Onkar Kulkarni
Hi
Use the below code:
File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "Year_sales" ;
TEMP:
LOAD
Max(RPT_YEAR) as Current_Year
Resident File_status;
LET v_max_year = floor(peek('Current_Year'));
NOCONCATENATE
Final:
Load *
Resident File_status
where RPT_YEAR = $(v_max_year);
Drop Table TEMP;
Drop Table File_status;
Hi
Use the below code:
File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "Year_sales" ;
TEMP:
LOAD
Max(RPT_YEAR) as Current_Year
Resident File_status;
LET v_max_year = floor(peek('Current_Year'));
NOCONCATENATE
Final:
Load *
Resident File_status
where RPT_YEAR = $(v_max_year);
Drop Table TEMP;
Drop Table File_status;
You may simply restrict the year while fetching from Oracle, e.g.
...
SELECT
RPT_YEAR
FROM "Year_sales"
WHERE RPT_YEAR = EXTRACT(YEAR FROM SYSDATE)
Hi,
Try This
File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "Year_sales" ;
TEMP:
LOAD
Max(Floor(RPT_YEAR)) as Current_Year
Resident File_status;
LET v_max_year = peek('Current_Year');
Drop Table TEMP;
Drop Table File_status;
Final:
Load *
FROM "Year_sales"
where RPT_YEAR = $(v_max_year);
Thanks,
Naresh
Thanks for the quick reply. I cannot use sysdate as not necessary the max (year) will be sysdate year. sometimes latest year could be 2015 in data.