Error in using aggregate function in Outer Query in Siebel Analytics
Hi,
When I am using aggregate function in outer query in Siebel Analytics I am facing error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 59111] The SQL statement must include a GROUP BY clause. (HY000)
Bellow is the code.
SELECT test1.username saw_0, test1.desg saw_1,COUNT (test2.querydate) saw_2
FROM (SELECT POSITION.CBL username,
POSITION.CBP desg
FROM "CM"
WHERE (POSITION.BPTCD = 'Marketing')
AND (POSITION.EDate =TIMESTAMP '1899-01-01 00:00:00'
) test1,
(SELECT users.UN username,
measures."Query Count" querycount,
measures."Max Total Time" secs,
topic.db dashboardname,
"Query Time".DATE querydate
FROM "Plan"
WHERE (topic."Dashboard Name" IN ('DS'))) test2
WHERE test2.username = LOWER (test1.username)
AND test2.dashboardname = 'DS'
GROUP BY test1.username, test1.desg
Should your query be a valid SQL query?
I can't think that the query you have would be valid in a SQL plus window.
Chris
Similar Messages
-
Facing problem while using aggregate functions.
I am trying to use aggregate functions such as sum, count in my CQL query.
It is not giving me an error but i am unable to get the correct output out of that.
Query is:
<?xml version="1.0" encoding="UTF-8"?>
<wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
xmlns:jdbc="http://www.oracle.com/ns/ocep/config/jdbc">
<processor>
<name>APL_EFW_CostEvent_Processor</name>
<rules>
<view id="CostEventView"
schema="eventName eventType eventId opportunityStatusId opportunity_cost APL_Event_Inbound"><![CDATA[
SELECT X.eventName, X.eventType,
X.eventId, X.opportunityStatusId,
X.opportunity_cost,X.APL_Event_Inbound
from APL_EFW_Master_Inbound_Channel
XMLTable (
'/' PASSING BY VALUE APL_EFW_Master_Inbound_Channel.APL_Event_Inbound as "."
COLUMNS
eventId char(256) PATH 'fn:data(Event/EventHeader/eventId)',
eventName char(256) PATH 'fn:data(Event/EventHeader/eventName)',
eventType char(256) PATH 'fn:data(Event/EventHeader/eventType)',
opportunityStatusId char(256) PATH 'fn:data(Event/ApplicationDataArea/opportunity/opportunity_details/opportunity_status)',
opportunity_cost char(256) PATH 'fn:data(Event/ApplicationDataArea/opportunity/opportunity_details/opportunity_cost)',
APL_Event_Inbound xmltype path '/'
) AS X
]>
</view>
<query id="CostEventQuery">
<![CDATA[
SELECT
XMLELEMENT("opportunity",
XMLELEMENT("cost_opportunity",
XMLFOREST(X.opportunity_cost))) as APL_Event_Inbound
FROM CostEventView
MATCH_RECOGNIZE (
MEASURES
A.opportunity_cost as opportunity_cost
PATTERN (B A+) within 30000 milliseconds
DEFINE
A as sum(A.opportunity_cost)> 1000 )
as X
]]>
</query>
</rules>
</processor>
</wlevs:config>
The problem i am getting is when the value is getting compared with the opportunity cost rather than with the sum of oppCost
A as sum(A.opportunityCost)>1000
A as A.opportunityCost >1000
Both the cases are treated as same .It would help if you could provide sample input data and associated output that illustrates the problem
-
Using Aggregate function in queries
Hi all,
Please take a look on this query and suggest me why i'm getting the error..
This is my simple query using aggregate function in it..
SELECT T1.NAME, T1.DESCRIPTION, SUM(T2.QUANTITY)
FROM TABLE1 T1, TABLE2 T2
WHERE T1.ID=T2.ID
GROUP BY T1.NAME, T1.DESCRIPTION
Above query added with a sub-query in the select segment..
SELECT T1.NAME, T1.DESCRIPTION, SUM(T2.QUANTITY), (SELECT AVG(T3.PRICE) FROM TABLE1 TT1, TABLE3 T3 WHERE TT1.ID=T3.ID AND TT1.ID=T1.ID) AV_PRICE
FROM TABLE1 T1, TABLE2 T2
WHERE T1.ID=T2.ID
GROUP BY T1.NAME, T1.DESCRIPTION
When i add a sub-query which has aggregate function in it, i'm getting the 'ORA-00979: not a GROUP BY expression' error.What is your DB Version. Your query works without any issue in my DB. I used WITH clause to create the sample data. The query highlighted in BLUE is the actual query.
SQL> select * from v$version where rownum = 1;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
SQL> with table1
2 as
3 (
4 select 1 id, 'karthick' name, 'user name' description from dual
5 ),
6 table2
7 as
8 (
9 select 1 id, 100 quantity from dual
10 ),
11 table3
12 as
13 (
14 select 1 id, 10 price from dual
15 )
16 select t1.name
17 , t1.description
18 , sum(t2.quantity)
19 , (
20 select avg(t3.price)
21 from table1 tt1
22 , table3 t3
23 where tt1.id = t3.id
24 and tt1.id = t1.id
25 ) av_price
26 from table1 t1
27 , table2 t2
28 where t1.id = t2.id
29 group
30 by t1.name
31 , t1.description;
NAME DESCRIPTI SUM(T2.QUANTITY) AV_PRICE
karthick user name 100 10
SQL> -
Problem while using aggregate functions in EJB QL 2.1
Hai all,
I am using aggregate function as follows
select max(c.id) from customer as c
for this iam selected check box EJB QL 2.1 in persistent.xml
this is validated by nwds, but while deploying server raising error like ejb ql syntax error.
Actually according to EJB QL 2.1 this is a valid query, what i need to do for run this same query .
Anybody please help me in this regard
Regards
SomarajuBeevin
Both two are not even validated,
but with the first one as select max(c.id) from customer as c , in this case it is validated but while deploying it is error as , object must be return
But when i saw the ejb2.1 specification we can write this type of queries also ?
Is it problem with was any thing
Regards
Somaraju -
Problem in using aggregate functions inside case statement
Hi All,
I am facing problem while using aggregate functions inside case statement.
CASE WHEN PSTYPE='S' THEN MAX(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ELSE SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) END,
how can I achieve above requirement ? Con anyone help me.
Thanks and Regards
DGHi All,
Below is my query:
SELECT
CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT
ELSE POS.PACCT || '-' || DECODE(POS.SYSTEMCODE,'GMI1','1', 'GMI2','2', 'GMI3','4', 'GMI4','3', '0') ||POS.PFIRM|| NVL(POS.POFFIC,'000') END,
CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-')
ELSE POS.PFIRM||POS.POFFIC||POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-') END,POS.SYSTEMCODE,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,POS.PEXCH||DECODE(POS.PSUBEX,'<NULL>',''),
POS.PCURSY,
CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END ,
NVL(POS.PSUBTY,'F') ,POS.PSTRIK,*SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ,SUM(DECODE(POS.PBS,2,ABS(POS.PPRTQ),0))* ,
POS.PCLOSE,SUM(POS.PMKVAL) ,
TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
POS.UBS_ID,POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER ,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,TO_CHAR(POS.BUSINESS_DATE,'YYYYMMDD'),
POS.SOURCE_GMI_LIB,
--DECODE(POS.SYSTEMCODE,'GMI1','euro','GMI2','namr','GMI3','aust','GMI4','asia','POWERBASE','aust','SINACOR','namr',POS.SYSTEMCODE),
DECODE(p_reportid,'RVPOS_SING','euro','RVPOS_AUSTDOM','aust','RVPOS_AUSTEOD','euro','RVPOS_GLBLAPAC','asia','POS_RV_SN','namr','POS_PB','aust',POS.SYSTEMCODE),
POS.RIC,
CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
NVL(C.SSECID,POS.PCUSIP),
NULL,
POS.PYSTMV,
POS.PMINIT,
POS.PEXPDT,
CASE WHEN POS.PSUBTY='S' THEN SUBSTR(C.ZDATA2,77,1) ELSE NULL END,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
FROM POSITIONS_WRK POS LEFT OUTER JOIN
(SELECT * FROM CDS_PRODUCTS CP INNER JOIN FUTURE_MASTER FM ON
(CP.STRXCH=FM.ZEXCH AND CP.SFC=FM.ZFC AND CP.BUSINESS_DATE = FM.BUSINESS_DATE )) C ON POS.PCUSIP = C.SCUSIP
AND NVL(POS.PCUSP2,'X') = NVL(C.SCUSP2,'X')
WHERE
POS.PEXCH NOT IN ('A1','A2','A3','B1','B3','C2','D1','H1','K1','L1','M1','M3','P1','S1')
AND (POS.PSBCUS IS NOT NULL OR POS.PCTYM IS NOT NULL OR POS.PSTYPE ='S')
AND POS.BUSINESS_DATE = run_date_char
GROUP BY
POS.UBS_ID,POS.SYSTEMCODE,POS.RECIPIENTCODE,POS.BUSINESS_DATE,POS.PACCT,POS.PFIRM,POS.POFFIC,POS.PCUSIP,POS.PBS,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,
POS.PEXCH,POS.PSUBEX,POS.PCURSY,
CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END,
NVL(POS.PSUBTY,'F') ,POS.PSTRIK,POS.PCLOSE,TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,POS.PSUBTY,POS.SOURCE_GMI_LIB,RIC,
CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
NVL(C.SSECID,POS.PCUSIP),
POS.PYSTMV,
POS.PMINIT,
POS.PEXPDT,
CASE WHEN PSUBTY = 'S' THEN SUBSTR(C.ZDATA2,77,1) ELSE NULL END;Now, could you plz help me in replacing the bold text in the query with the requirement.
Thanks and Rgds
DG
Edited by: BluShadow on 16-May-2011 09:39
added {noformat}{noformat} tags. Please read: {message:id=9360002} for details on how to post code/data -
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 -
Any difference between distinct and aggregate function in sql query cost???
Hi,
I have executed many sql stmts patterns- such as:
a) using a single table
b) using two tables, using simple joins or outer joins
but i have not noticed any difference in sql stmts in cost and in execution plan....
Anyway, my colleague insists on that using aggregate function is less costly compared to
distinct....(something i have not confirmed, that's why i beleive that they are exactly the same...)
For the above reffered 1st sql pattern.. we could for example use
select distinct deptno
from emp
select count(*), deptno
from emp
group by deptno select distinct owner, object_type from all_objects
select count(*), owner, object_type from all_objects
group by owner, object_typeHave you found any difference between the two ever...????
Note: I use Ora DB 10g v2.
Thank you,
Simdistinct and aggregate function are for different uses and may give same result but if u r using aggregate function to get distinct records, it will be expensive...
ex
select distinct deptno from scott.dept;
Statistics
0 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
584 bytes sent via SQL*Net to client
488 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
4 rows processed
select deptno from scott.emp group by deptno;
Statistics
307 recursive calls
0 db block gets
60 consistent gets
6 physical reads
0 redo size
576 bytes sent via SQL*Net to client
488 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
3 rows processed
Nimish Garg
Software Developer
*(Oracle & ASP.NET)*
Indiamart Intermesh Limited, Noida
To Get Free Oracle & ASP.NET Code Snippets
Follow: http://nimishgarg.blogspot.com -
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. -
ORA-00902: invalid datatype comile error while using CAST function
Hi everyone,
I'm getting ORA-00902: invalid datatype compilation error while using CAST function.
open ref_cursor_list for select empName from TABLE(CAST(part_t AS partnumberlist));
The partnumberlist and ref_cursor_list is declared in the Package spec as given below.
TYPE ref_cursor_list IS REF CURSOR;
TYPE partnumberlist IS TABLE OF emp.empName%TYPE;
The error points the partnumberlist as invalid datatype in TOAD because of this i'm unable to compile the package.
Any suggestion
Thanks and regards
Sathish GopalHere is my code for
package Spec
CREATE OR REPLACE PACKAGE "HISTORICAL_COMMENTZ" AS
TYPE prior_part_data_record IS RECORD (
prior_part_row_id PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE,
prior_pgm_chng_s_id PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE
TYPE parts_list IS TABLE OF prior_part_data_record;
--TYPE parts_list IS TABLE OF NUMBER;
TYPE partnumberlist IS TABLE OF PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE;
TYPE partnumber_cursor IS REF CURSOR;
TYPE comment_record IS RECORD (
pgm_s_id PGM_PART_CMNT.PGM_S_ID%TYPE,
part_row_s_id PGM_PART_CMNT.PART_ROW_S_ID%TYPE,
pgm_chng_s_id PGM_PART_CMNT.PGM_CHNG_S_ID%TYPE,
cmnt_txt PGM_PART_CMNT.CMNT_TXT%TYPE,
cmnt_dt PGM_PART_CMNT.CMNT_DT%TYPE,
updt_rsrc_id PGM_PART_CMNT.UPDT_RSRC_ID%TYPE
TYPE comment_list IS TABLE OF comment_record;
global_pgm_s_id INTEGER := 0;
global_part_row_s_id INTEGER := 0;
err_num NUMBER := 999999;
err_msg VARCHAR2 (250);
PROCEDURE getComments (
pgm_s_id IN NUMBER,
part_row_s_id IN NUMBER,
partnumber_cursorlist out partnumber_cursor);
END;
Package Body
CREATE OR REPLACE PACKAGE BODY HISTORICAL_COMMENTZ
AS
FUNCTION getPriorPart
(param_prior_pgm_chng_s_id IN PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE,
return_prior_part_data_record IN OUT prior_part_data_record
RETURN INTEGER
IS
retVal INTEGER;
prior_part_row_id INTEGER;
prior_pgm_chng_s_id INTEGER;
local_prior_part_data_record prior_part_data_record;
BEGIN
SELECT PR_PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
INTO local_prior_part_data_record
--SELECT PR_PART_ROW_S_ID INTO retVal
FROM PGM_RPLCMNT_PART
WHERE PGM_S_ID = global_pgm_s_id AND CUR_PGM_CHNG_S_ID = param_prior_pgm_chng_s_id;
return_prior_part_data_record := local_prior_part_data_record;
retVal := 0;
RETURN retVal;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
retVal := -1;
RETURN retVal;
WHEN OTHERS
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
retVal := -1;
RETURN retVal;
END getPriorPart;
FUNCTION getComment (found_parts_list IN parts_list, comments OUT comment_list)
RETURN INTEGER
IS
CURSOR init_cursor
IS
SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
FROM PGM_PART_CMNT WHERE 1 = 2;
retVal INTEGER;
indexNum PLS_INTEGER;
local_part_record prior_part_data_record;
local_comment_record comment_record;
local_part_row_s_id NUMBER;
i PLS_INTEGER;
BEGIN
OPEN init_cursor;
FETCH init_cursor
BULK COLLECT INTO comments;
i := 0;
indexNum := found_parts_list.FIRST;
WHILE indexNum IS NOT NULL
LOOP
local_part_record := found_parts_list(indexnum);
local_part_row_s_id := local_part_record.prior_part_row_id;
SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
INTO local_comment_record FROM PGM_PART_CMNT
WHERE PGM_S_ID = global_pgm_s_id
AND PART_ROW_S_ID = local_part_row_s_id;
comments(i) := local_comment_record;
i := i + 1;
END LOOP;
RETURN retval;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
RETURN retval;
WHEN OTHERS
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
RETURN retval;
END getComment;
PROCEDURE getComments
pgm_s_id IN NUMBER,
part_row_s_id IN NUMBER,
partnumber_cursorlist OUT partnumber_cursor)
IS
comment_recordlist comment_record;
retPartnumberlist partnumberlist;
found_parts_list parts_list;
local_part_record prior_part_data_record;
is_more_parts BOOLEAN;
driver_chng_s_id NUMBER;
num_parts NUMBER;
retVal NUMBER;
comments comment_list;
returnPartnumberlist partnumberlist;
iloopCounter PLS_INTEGER;
inx1 PLS_INTEGER;
part_t partnumberlist :=partnumberlist(100,200,300);
CURSOR part_list_init_cursor
IS
SELECT PR_PART_ROW_S_ID,PR_PGM_CHNG_S_ID FROM PGM_RPLCMNT_PART WHERE 1 = 2;
CURSOR inIt_cursor
IS
SELECT 0 FROM DUAL WHERE 1 = 2;
BEGIN
DBMS_OUTPUT.ENABLE (5000000);
global_pgm_s_id := pgm_s_id;
global_part_row_s_id := part_row_s_id;
SELECT PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
INTO local_part_record
FROM PGM_RPLCMNT_PART
WHERE PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id AND
CUR_PGM_CHNG_S_ID IN (SELECT MAX(CUR_PGM_CHNG_S_ID) FROM PGM_RPLCMNT_PART WHERE
PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id
GROUP BY PART_ROW_S_ID);
OPEN part_list_init_cursor;
FETCH part_list_init_cursor
BULK COLLECT INTO found_parts_list;
-- Add the existing part to the found list
found_parts_list.EXTEND;
found_parts_list(1) := local_part_record;
driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
num_parts := 1;
is_more_parts := TRUE;
WHILE (is_more_parts) LOOP
retVal := getPriorPart(driver_chng_s_id,local_part_record);
IF (retVal != -1) THEN
found_parts_list.EXTEND;
num_parts := num_parts + 1;
found_parts_list(num_parts) := local_part_record;
driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
ELSE
is_more_parts := FALSE;
END IF;
END LOOP;
--num_parts := getComment(found_parts_list,comments);
OPEN init_cursor;
FETCH init_cursor
BULK COLLECT INTO returnPartnumberlist;
num_parts := found_parts_list.COUNT;
FOR iloopCounter IN 1 .. num_parts
LOOP
returnPartnumberlist.EXTEND;
returnPartnumberlist(iloopCounter) := found_parts_list(iloopCounter).prior_part_row_id;
END LOOP;
retPartnumberlist := returnPartnumberlist;
open
* partnumber_cursorlist for select PR_PART_ROW_S_ID from TABLE(CAST(retPartnumberlist AS historical_commentz.partnumberlist));*
DBMS_OUTPUT.put_line('Done....!');
EXCEPTION
some code..............................
END getComments;
END HISTORICAL_COMMENTZ;
/ -
Using aggregate function count
hi experts,
I want to select 2 fields from a table and put into structure (gw_konzs.) and with respect to that i want to use aggregate function count(*) for knowing how many rows has been selected ? and i dont want to use select & endselect
please help regarding this ...........
for example:
select konts ltext from ztab into corresponding fields of gw_konzs.
select count(*) from kna1 into gw_konzs
where konzs = gw_konzs-konzs.
append gw_konzs to gt_konzs
endselect.hi experts,
I want to select 2 fields from a table and put into structure and i want to select based on the where condition i dont want to use select & endselect
please help regarding this ...........
rewarded if useful
for example:
gw_detail & gw_konzs is structure
gt_detail & gt_konzsis internal table
select kunnr name1 from kna1 into corresponding fields of gw_detail where konzs = gw_konzs-konzs.
gw_detail-konzs = gw_konzs-konzs.
append gw_detail-konzs to gt_detail-konzs
endselect. -
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 -
Can I use table function inside Dynamic query ?
Dear Gurus,
I have following code
DECLARE
TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
QUERY_STRING VARCHAR2(4000);
BEGIN
OtherNoList := CRITERIA_LIST_TABLE();
SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
'SELECT C1,'||
'C2 '||
'FROM TAB1 ,'||
'TABLE( '||
'CAST (OtherNoList AS CRITERIA_LIST_TABLE) '||
') OTHRNOS '||
'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
EXECUTE IMMEDIATE QUERY_STRING;
END;
Can I use Table function inside dynamic query.
Thanking in advance
SanjeevTry:
DECLARE
TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
QUERY_STRING VARCHAR2(4000);
BEGIN
OtherNoList := CRITERIA_LIST_TABLE();
SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
'SELECT C1,'||
'C2 '||
'FROM TAB1 ,'||
'TABLE( '||
'CAST (:OtherNoList AS CRITERIA_LIST_TABLE) '||
') OTHRNOS '||
'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
EXECUTE IMMEDIATE QUERY_STRING using OtherNoList;
END;p.s. not tested
Amiel Davis -
Error in Using Aggregate Persistence
Hi All,
I created an aggregate file called NewScript.sql in C drive using aggregate persistence wizard.
And am trying to run the file using command prompt using following command ..
C:\OracleBI\server\Bin>nqcmd.exe -d AnalyticsWeb -u Administrator -p Administrator -s c:NewScript.sql
and i get the following error..
Open Input file failed
Please help me to create the aggregate tables..
Thanks in advance..
Regards
MehaboobHi Dpka,
Sorry for the late reply.
I executed the script in sql server 2008 and got the following error.
"Msg 343, Level 15, State 1, Line 1
Unknown object type 'aggregates' used in a CREATE, DROP, or ALTER statement."
This is my query
create aggregates
*"ag_GL_Fact"*
for "Finance"."GL Fact"("Revenue","Avg Of Revenue")
at levels ("Finance"."GL Accounts"."Acc Type", "Finance"."Posting Time"."Quarter")
using connection pool "arj"."Arj Connection Pool"
in "arj"."Arj"."dbo";
Regards
Mehaboob -
Issue in pivot while using aggregate functions
when I use this below query in oracle sql developer
------------->select sum(round(8.08/0.54,2)*30) from dual.
i am getting result as 448.8.it is a correct value
but i use this below queries in pivot as same like above query i am getting result of doubled value 914.4.
PIVOT
SUM(round(ROUND(sellout,2)/6,2)) AS LAST_6_MON_SELL_OUT,
SUM(ROUND(inventory,2)) AS INVENTORY_INTINS_1,
Sum(round(ROUND(inventory,2)/round(ROUND(sellout,2)/6,2),2)*30) As Stockperday
FOR PRODUCT IN (56,78)
actually i am getting value for SUM(round(ROUND(sellout,2)/6,2)) is 0.54,*SUM(ROUND(inventory,2))* is 8.08 i the above query ,but i am getting wrong value for this aggregate function Sum(round(ROUND(inventory,2)/round(ROUND(sellout,2)/6,2),2)30)* as 914.4.but actual value is 448.8
why this problem.can anybody explain me.why this problemTry ur luck in 'sql plsql thread'
PL/SQL -
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.
Maybe you are looking for
-
How to Pass a BufferedImage? Client - Server
Please Help! I've been trying to figure out how to send a BufferedImage from my client program to the server program. I'm using a socket to create the connection. The client draws into a BufferedImage and then it is sent to the server to be saved as
-
Download Developer 6.0 with problem to unzip
I downloaded the Developer 6.0 from Oracle technet site several times, and every time when I tried to unzip the software, I recieved the same error message "Cannot open file:It does not appear to be a valid archive." Does any body know why? and how c
-
PersistenceManager Patterns for Multithreaded Applications
Hi, I'm looking for a good way, how to use Kodo JDO in a multithread application (actually Tomcat ;). The most easy thing is perhaps, to use only one persistence manager for the entire application, i.e. for all threads. Another solution might be, to
-
XML-Based Tracking Function...
My question is, while I track correct and incorrect responses AND report these at the end of the quiz, what would be the best method to track specific questions so that I cna offer the quiz taker a review of incorrect responses. The review would repr
-
Urgent: Missing (ovmm_)mysql binaries, please help
Owing to a mistake (understatement of the year) on my part I've managed to blow away all of the mysql binaries in /usr/bin. I imagine they all came with the MySQL installed with Oracle VM. Does anyone know the best way to replace the following: /us