How to use aggregate function with Toplink
Hi
My question is how can I get the following select when using Toplink-EJB.3:
SELECT MAX(fieldname) FROM tablename;
Thanasi
Hi KAVI PRIYA,
if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
please advise me,
Thanks,
Sri
Similar Messages
-
How to use aggregate function with Date
Hi All,
I have a group of date from that is it possible to Max and Min of date.
I have tried like this but its errored out <?MIN (current-group()/CREATION_DATE)?>.
I have also tried like this but it doesnt works
<?xdoxslt:minimum(CREATION_DATE)?>
Is it possible to use aggregate function with date values.
Thanks & Regards
SrikkanthHi KAVI PRIYA,
if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
please advise me,
Thanks,
Sri -
How to use Aggregate Functions during Top N analysis?
Say i want to find top 5 highest salaries and their totals and average. In that case how to use aggregate functions. Please give me an example on this.
Regards,
Renu
Message was edited by:
user642387Hi,
Yes, you can do that with aggregate functions.
First, do a sub-query to retrieve all the salaries (in descending order), then say "WHERE ROWNUM <= 5" in the main query. Use the aggregate SUM and AVG functions in the main query.
Analytic functions are easier to use for jobs like this, once you get familiar with them. If you're not leaving the field this month, then it's probably worthwhile for you to get familiar with analytic functions. -
How to use TRUNC function with dates in Expression Builder in OBIEE.
Hi There,
How to use TRUNC function with dates in Expression Builder in OBIEE.
TRUNC (SYSDATE, 'MM') returns '07/01/2010' where sysdate is '07/15/2010' in SQL. I need to use the same thing in expression builder in BMM layer logical column.
Thanks in advanceuse this instead:
TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(CURRENT_DATE) * -1) + 1, CURRENT_DATE) -
How to use INVOKE function with INT parameter types
Can you tell me how to use invoke function with int parameter type ?
Pass the int as an Integer.
-
How to use aggregate functions into Analytical functions
Can we use aggregate functions into analytical functions?
Please provide one example.
Smiles.HI Learner6
for information:
Aggregate Functions
Analytic Functions
for practic:
ORACLE-BASE - Analytic Functions
Thank you -
How to use REF cursor with toplink
Hi,
I have a stored proc has a out variable which is a REF CURSOR.
How to read my cursor with toplink?I have got it. Here is the solution.
UnitOfWork uow= dbSession.acquireUnitOfWork();
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("smart.getCompanyStruct");
call.addNamedArgument("xnrid");
call.useNamedCursorOutputAsResultSet("cpy");
DataReadQuery query = new DataReadQuery();
query.setCall(call);
Vector parameters = new Vector();
query.addArgument("xnrid");
parameters.add(new Long(5009L));
Vector obj = (Vector) uow.executeQuery(query, parameters);
Vector contains result ser of the cursor
Gurcan -
How to use analytic function with aggregate function
hello
can we use analytic function and aggrgate function in same qurey? i tried to find any example on Net but not get any example how both of these function works together. Any link or example plz share with me
Edited by: Oracle Studnet on Nov 15, 2009 10:29 PMselect
t1.region_name,
t2.division_name,
t3.month,
t3.amount mthly_sales,
max(t3.amount) over (partition by t1.region_name, t2.division_name)
max_mthly_sales
from
region t1,
division t2,
sales t3
where
t1.region_id=t3.region_id
and
t2.division_id=t3.division_id
and
t3.year=2004
Source:http://www.orafusion.com/art_anlytc.htm
Here max (aggregate) and over partition by (analytic) function is in same query. So it means we can use aggregate and analytic function in same query and more than one analytic function in same query also.
Hth
Girish Sharma -
How to use aggregate function on internal table
hi experts,
I am beginner in abap.I want to use sum function on internal table.
I have structure as follow:
types: begin of ty_ftab,
docno TYPE bkpf-belnr,
comcode TYPE bkpf-bukrs,
year TYPE bkpf-gjahr,
line_itm type bsad-buzei,
cust type bsad-kunnr,
amt type bsad-dmbtr,
end of ty_ftab.
data: it_ftab type table of ty_ftab,
wa_ftab type ty_ftab.
i fetched data successfully into it_ftab from bkpf and bsad table and displyed into alv.
now i want sum of amt using group by cust and want to display like
cust total_amt
in next screen...
displying part is not important but how can i do sum of amt according to cust value? Is there in way to query on internal table?Hi,
try this code,
data : i_sort TYPE TABLE OF slis_sortinfo_alv
w_sort like LINE OF i_sort.
sort it_ftab by cust.
w_sort-subtot = 'X'.
w_sort-fieldname = 'AMT'.
w_sort-tabname = 'it_ftab'.
APPEND w_sort to i_sort.
In fieldcatalog :
w_fcat-fieldname = 'AMT'.
w_fcat-tabname = 'it_ftab'.
w_fcat-do_sum = 'X'.
In REUSE_ALV_GRID_DISPLAY FUNCTION MODULE provide the it_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
* IT_FIELDCAT =
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = i_sort
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab =
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. -
How to use trignometric functions with MIDP1.0
HI ALL!
We designed midlet to run on a mobile phone using MIDP1.0. We have some additional trignometrical classes to integerate with the midlet. But we got astonished when we didn't find any trignometrical function in MIDP1.0 & CLDC1.0. It is now is a great panic for us.
It is very unbelievable that Sun Microsystem doesn't provide such classes with J2ME!!
Is there any way to define or get a free-ware trignometrical classes to use?
We hope reply from this Forum soon!Mmmm....,J2ME currently doesn't support doubles,floats and if you want to use trigonometric functions then you will use cos, sin, tan, ctan,atan,acos,asin and this means doubles and floats....
-
How to use Substring function with Case statement.
Hello Everyone,
I have one requirement where I have to use substring function on the field for report criteria.
E.G.
I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
now i want to substing it but the character length varies for each branch.
so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.Try something like this:
CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
where n is the number of characters you want to start the break. -
How to use aggregate function (min) with Date
Hi,
I am using below code to print min date.
<?if:SD_UserDefinedCode_KY_ID5 = 'LOESCH' or SD_UserDefinedCode_KY_ID5='FRIST'?>
<?xdoxslt:minimum_date(SD_EffectiveDate_EFT_ID28)?> <?end if?>
condition provide two date 2013-05-01 and 2013-01-01.
Date is in canonical format YYYY-MM-DD.
now result is coming like number 1293840000000
Minimum date should be come 2013-01-01 instead of 1293840000000 .
Could you please help me out.
Thanks
Indrajeet KumarHi KAVI PRIYA,
if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
please advise me,
Thanks,
Sri -
Oracle Data Mining - How to use PREDICTION function with a regression model
I've been searching this site for Data Mining Q&A specifically related to prediction function and I wasn't able to find something useful on this topic. So I hope that posting it as a new thread will get useful answers for a beginner in oracle data mining.
So here is my issue with prediction function:
Given a table with 17 weeks of sales for a given product, I would like to do a forecast to predict the sales for the week 18th.
For that let's start preparing the necessary objects and data:
CREATE TABLE T_SALES
PURCHASE_WEEK DATE,
WEEK NUMBER,
SALES NUMBER
SET DEFINE OFF;
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('11/27/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 1, 55488);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('12/04/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 2, 78336);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('12/11/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 3, 77248);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('12/18/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 4, 106624);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('12/25/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 5, 104448);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('01/01/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 6, 90304);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('01/08/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 7, 44608);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('01/15/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 8, 95744);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('01/22/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 9, 129472);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('01/29/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 10, 110976);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('02/05/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 11, 139264);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('02/12/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 12, 87040);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('02/19/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 13, 47872);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('02/26/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 14, 120768);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('03/05/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 15, 98463.65);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('03/12/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 16, 67455.84);
Insert into T_SALES
(PURCHASE_WEEK, WEEK, SALES)
Values
(TO_DATE('3/19/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 17, 100095.66);
COMMIT;
There are a lot of linear regression models and approaches for sales forecast out on the market, however I will focus on what oracle 11g offers i.e. package SYS.DBMS_DATA_MINING to create a model using regression as mining function and then, once the model is created, to apply prediction function on the model.
Therefore I'll have to go through few steps:
i) normalization of data
CREATE OR REPLACE VIEW t_sales_norm AS
SELECT week,
sales,
(sales - 91423.95)/27238.3693126778 sales_norm
FROM t_sales;
whereas the numerical values are the mean and the standard deviation:
select avg(sales) from t_sales;
91423.95
select stddev(sales) from t_sales;
27238.3693126778
ii) auto-correlation. For the sake of simplicity, I will safely assume that there is no auto-correlation (no repetitive pattern in sales among the weeks). Therefore to define the lag data I will consider the whole set:
CREATE OR REPLACE VIEW t_sales_lag AS
SELECT a.*
FROM (SELECT week,
sales,
LAG(sales_norm, 1) OVER (ORDER BY week) L1,
LAG(sales_norm, 2) OVER (ORDER BY week) L2,
LAG(sales_norm, 3) OVER (ORDER BY week) L3,
LAG(sales_norm, 4) OVER (ORDER BY week) L4,
LAG(sales_norm, 5) OVER (ORDER BY week) L5,
LAG(sales_norm, 6) OVER (ORDER BY week) L6,
LAG(sales_norm, 7) OVER (ORDER BY week) L7,
LAG(sales_norm, 8) OVER (ORDER BY week) L8,
LAG(sales_norm, 9) OVER (ORDER BY week) L9,
LAG(sales_norm, 10) OVER (ORDER BY week) L10,
LAG(sales_norm, 11) OVER (ORDER BY week) L11,
LAG(sales_norm, 12) OVER (ORDER BY week) L12,
LAG(sales_norm, 13) OVER (ORDER BY week) L13,
LAG(sales_norm, 14) OVER (ORDER BY week) L14,
LAG(sales_norm, 15) OVER (ORDER BY week) L15,
LAG(sales_norm, 16) OVER (ORDER BY week) L16,
LAG(sales_norm, 17) OVER (ORDER BY week) L17
FROM t_sales_norm) a;
iii) choosing the training data. Again, I will choose the whole set of 17 weeks, as for this discussion in not relevant how big should be the set of training data.
CREATE OR REPLACE VIEW t_sales_train AS
SELECT week, sales,
L1, L2, L3, L4, L5, L6, L7, L8, L9, L10,
L11, L12, L13, L14, L15, L16, L17
FROM t_sales_lag a
WHERE week >= 1 AND week <= 17;
iv) build the model
-- exec SYS.DBMS_DATA_MINING.DROP_MODEL('t_SVM');
BEGIN
sys.DBMS_DATA_MINING.CREATE_MODEL( model_name => 't_SVM',
mining_function => dbms_data_mining.regression,
data_table_name => 't_sales_train',
case_id_column_name => 'week',
target_column_name => 'sales');
END;
v) finally, where I am confused is applying the prediction function against this model and making sense of the results.
On a search on Google I found 2 ways of applying this function to my case.
One way is the following:
SELECT week, sales,
PREDICTION(t_SVM USING
LAG(sales,1) OVER (ORDER BY week) as l1,
LAG(sales,2) OVER (ORDER BY week) as l2,
LAG(sales,3) OVER (ORDER BY week) as l3,
LAG(sales,4) OVER (ORDER BY week) as l4,
LAG(sales,5) OVER (ORDER BY week) as l5,
LAG(sales,6) OVER (ORDER BY week) as l6,
LAG(sales,7) OVER (ORDER BY week) as l7,
LAG(sales,8) OVER (ORDER BY week) as l8,
LAG(sales,9) OVER (ORDER BY week) as l9,
LAG(sales,10) OVER (ORDER BY week) as l10,
LAG(sales,11) OVER (ORDER BY week) as l11,
LAG(sales,12) OVER (ORDER BY week) as l12,
LAG(sales,13) OVER (ORDER BY week) as l13,
LAG(sales,14) OVER (ORDER BY week) as l14,
LAG(sales,15) OVER (ORDER BY week) as l15,
LAG(sales,16) OVER (ORDER BY week) as l16,
LAG(sales,17) OVER (ORDER BY week) as l17
) pred
FROM t_sales a;
WEEK, SALES, PREDICTION
1, 55488, 68861.084076412
2, 78336, 104816.995823913
3, 77248, 104816.995823913
4, 106624, 104816.995823913
As you can see for the first row there is a value of 68861.084 and for the rest of 16 values is always one and the same 104816.995.
Question: where is my week 18 prediction ? or maybe I should say which one is it ?
Another way of using prediction even more confusing is against the lag table:
SELECT week, sales,
PREDICTION(t_svm USING a.*) pred
FROM t_sales_lag a;
WEEK, SALES, PREDICTION
1, 55488, 68861.084076412
2, 78336, 75512.3642096908
3, 77248, 85711.5003385927
4, 106624, 98160.5009687461
Each row out of 17, its own 'prediction' result.
Same question: which one is my week 18th prediction ?
Thank you very much for all help that you can provide on this matter.
It is as always highly appreciated.
Serge F.Kindly let me know how to give input to predict the values for example script to create model is as follows
drop table data_4svm
drop table svm_settings
begin
dbms_data_mining.drop_model('MODEL_SVMR1');
CREATE TABLE data_4svm (
id NUMBER,
a NUMBER,
b NUMBER
INSERT INTO data_4svm VALUES (1,0,0);
INSERT INTO data_4svm VALUES (2,1,1);
INSERT INTO data_4svm VALUES (3,2,4);
INSERT INTO data_4svm VALUES (4,3,9);
commit;
--setting table
CREATE TABLE svm_settings
setting_name VARCHAR2(30),
setting_value VARCHAR2(30)
--settings
BEGIN
INSERT INTO svm_settings (setting_name, setting_value) VALUES
(dbms_data_mining.algo_name, dbms_data_mining.algo_support_vector_machines);
INSERT INTO svm_settings (setting_name, setting_value) VALUES
(dbms_data_mining.svms_kernel_function, dbms_data_mining.svms_linear);
INSERT INTO svm_settings (setting_name, setting_value) VALUES
(dbms_data_mining.svms_active_learning, dbms_data_mining.svms_al_enable);
COMMIT;
END;
--create model
BEGIN
DBMS_DATA_MINING.CREATE_MODEL(
model_name => 'Model_SVMR1',
mining_function => dbms_data_mining.regression,
data_table_name => 'data_4svm',
case_id_column_name => 'ID',
target_column_name => 'B',
settings_table_name => 'svm_settings');
END;
--to show the out put
select class, attribute_name, attribute_value, coefficient
from table(dbms_data_mining.get_model_details_svm('MODEL_SVMR1')) a, table(a.attribute_set) b
order by abs(coefficient) desc
-- to get predicted values (Q1)
SELECT PREDICTION(MODEL_SVMR1 USING *
) pred
FROM data_4svm a;
Here i am not sure how to predict B values . Please suggest the proper usage . Moreover In GUI (.NET windows form ) how user can give input and system can respond using the Q1 -
How to use join queries with toplink
Hi there
I'm using toplink within the JDeveloper 10.1.3.3. with great success.
Now, I need to query multiple tables using a join SQL.
How do you configure toplink now without creating database views?
I could not find an easy with within the JDev IDE or from google search.
Any help please?
Thanks
HenkieIn a TopLink query you can query across any relationship to another object. You can also join or batch read the object's relationship using the ObjectLevelReadQuery and ReadAllQuery API (see TopLink documentation).
You can also map a class to multiple tables.
-- James : http://www.eclipselink.org -
How to use LIKE function with a parameter in Oracle REPORT builder??
how could i use parameter inside a LIKE function in Oracle reports builder?
it works in SQL plus, but not in report builder!!
Example:
select code,desc from item_master where desc
like '%&give_desc%'; ---works in SQL
like '%:give_desc%' ---doesn't work in report builder!!Hi Renil,
You will need to use the wildcard character (%) and the concatenation character (||) to join to your user parameter.
i.e. like '%'||:give_desc||'%'
Regards,
John
Maybe you are looking for
-
How to use a query in matrix data retrive
hai everybody how to use a query in matrix data retrive... pls ..
-
How to listen for cell selection changes within a JTable
Problem: my table has 8 columns, with 4 of them containing very large text (up to 1000 chars). Solution is to set the initial size these columns so that the 1st 20 chars are visible, and if one of these columns gains focus/selection via mouse-clickin
-
How to trak button content?
Hi Expert!, in step loop i have created 6 buttons and i'm printing PO number on the button insted of button text(Purchase order is printed as text label).Now i have been asked to retrieve the PO from selected button. I'm unable to
-
Pass a parameter from webi to Xcelsius
Hi all, Anybody knows how to pass a parameter from a webi report to Xcelsius via URL? I need to refresh the Xcelsius data with a parameter coming from the webi report. With Live Office works but only the first time: the data is not being refreshed in
-
Sorry about that. Here's the code to one of the affected pages. Kate <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" http://www.w3.org/1999/xhtml"> <head> <meta