Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SQL1
select FS_PERM_SEC_ID, avg(p_price) avg_price, 'DAY' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES'
and SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -1) and sysdate
group by FS_PERM_SEC_ID
UNION ALL
select FS_PERM_SEC_ID, avg(p_price) avg_price, 'WEEK' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES'
and SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -7) and sysdate
group by FS_PERM_SEC_ID
UNION ALL
select FS_PERM_SEC_ID, avg(p_price) avg_price, 'MONTH' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES'
and SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -30) and sysdate
group by FS_PERM_SEC_ID
UNION ALL
select FS_PERM_SEC_ID, avg(p_price) avg_price, 'QUARTER' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES'
and SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -90) and sysdate
group by FS_PERM_SEC_ID
UNION ALL
select FS_PERM_SEC_ID, avg(p_price) avg_price, 'YEAR' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES'
and SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -365) and sysdate
group by FS_PERM_SEC_ID;
@daniilyar

This comment has been minimized.

Copy link
Owner Author

daniilyar commented Aug 19, 2014

Result:

XQC8FD-S-ES 7.314 DAY
XQC8FD-S-ES 7.249 WEEK
XQC8FD-S-ES 7.4003 MONTH
XQC8FD-S-ES 7.43192222222222222222222222222222222222 QUARTER
XQC8FD-S-ES 6.32793261455525606469002695417789757412 YEAR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.