Title: User-Defined Aggregate Functions in Oracle SQL developer
Tags: sql;oracle
Question: I don't know how to create User-Defined Aggregate Functions which should do exactly the same job such as my stored procedure. My function should contain two input attributes, there are price and timer. (Sorry for my bad english)
My procedure is:
CREATE OR REPLACE PROCEDURE "PRICE"
(key IN NUMBER) AS
pricer ARTICLE.PRICE%type;
BEGIN
SELECT price INTO pricer
FROM HistoryPrice
WHERE Key_article =key  AND TIMER=(select max(TIMER) FROM
HistoryPrice WHERE Key_article=key AND TIMER<=SYSDATE);


Here is another answer: Format will be like below. You need to change logic of select statement.
CREATE OR REPLACE function f_price
(p_price IN NUMBER,
p_timer in number
) return number as
pricer ARTICLE.PRICE%type;
BEGIN
SELECT price INTO pricer
FROM HistoryPrice
WHERE Key_article =key  AND TIMER=(select max(TIMER) FROM
HistoryPrice WHERE Key_article=key AND TIMER<=SYSDATE);
return pricer;
end;
Comment for this answer: I need to create user defined agregate function. Example is below on the link http://docs.oracle.com/cd/B28359_01/appdev.111/b28425/aggr_functions.htm

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:05/06/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<sql><oracle>', 'Title': 'User-Defined Aggregate Functions in Oracle SQL developer', 'ViewCount': 114, 'id': 43824927, 'user_AboutMe': None, 'user_AccountId': 10513482.0, 'user_DisplayName': 'Jefrey', 'user_Reputation': 23.0, 'user_Views': 12.0, 'user_id': 7748359.0}}