Using case statement in OWB expression builder
Hi All,
We are using OWB version 10.2.0.1.0. While using the below case statement We are getting the validation message as 'The expression is not properly formed'.
Case statement used in expression builder:
case when (INGRP1.CHARGETYPE in ('O','F') or INGRP1.TARIFF_GROUP in ('SMSINT','MMSINT')or ( INGRP1.CALL_TYPE = '002' and INGRP1.TARIFF_GROUP = 'MTV'))
then
(select call_zone_reltn_key from call_zone_reltn where
call_zone_cd=substr(case
when substr( INGRP1.B_SUBNO,1,2)='00'
then
substr( INGRP1.B_SUBNO,3)
else substr( INGRP1.B_SUBNO,1)
end,1,length(call_zone_cd))and rownum=1)
else -1
end
Kindly help me out in fixing this error or suggest any alternate way to use the above query in OWB expression builder.
Thanks,
Kabilan
946887 wrote:
Hi All,
We are using OWB version 10.2.0.1.0. While using the below case statement We are getting the validation message as 'The expression is not properly formed'.
Did you try to deploy the mapping ? Some time the expression validator gives wrong error messege.
Try to deploy the mapping and see if you are still getting this issue
Case statement used in expression builder:
case when (INGRP1.CHARGETYPE in ('O','F') or INGRP1.TARIFF_GROUP in ('SMSINT','MMSINT')or ( INGRP1.CALL_TYPE = '002' and INGRP1.TARIFF_GROUP = 'MTV'))
then
(select call_zone_reltn_key from call_zone_reltn where
call_zone_cd=substr(case
when substr( INGRP1.B_SUBNO,1,2)='00'
then
substr( INGRP1.B_SUBNO,3)
else substr( INGRP1.B_SUBNO,1)
end,1,length(call_zone_cd))and rownum=1)
else -1
end
Kindly help me out in fixing this error or suggest any alternate way to use the above query in OWB expression builder.
Thanks,
Kabilan
Similar Messages
-
Need help in this sql query to use Case Statement
hi All,
I have the below query -
SELECT DISTINCT OFFC.PROV_ID
,OFFC.WK_DAY
,CASE
WHEN OFFC.WK_DAY ='MONDAY' THEN 1
WHEN OFFC.WK_DAY ='TUESDAY' THEN 2
WHEN OFFC.WK_DAY ='WEDNESDAY' THEN 3
WHEN OFFC.WK_DAY ='THURSDAY' THEN 4
WHEN OFFC.WK_DAY ='FRIDAY' THEN 5
WHEN OFFC.WK_DAY ='SATURDAY' THEN 6
WHEN OFFC.WK_DAY ='SUNDAY' THEN 7
END AS DOW
,OFFC.OFFC_OPENG_TIME
,OFFC.OFFC_CLSNG_TIME
FROM GGDD.PROV_OFFC_HR OFFC
WHERE OFFC.PROV_ID='0000600'
WITH UR;
this query is bringing results in 6 differnt rows with opening and closing time for each day separately. I want to generate the data in one row with each day having opening and closing time, so for 7 days, total 14 columns with opening and closing time. But i am not able to do that using case statement.
can somebody help me in achieving that.
thanks,
iamhereHi,
Welcome to the forum!
That's called a Pivot .
Instead of having 1CASE expression, have 14, one for the opening and one for the closing time each day, and do GROUP BY to combine them onto one row.
SELECT OFFC.PROV_ID
, MIN (CASE WHEN OFFC.WK_DAY ='MONDAY' THEN OFFC.OFFC_OPENG_TIME END) AS mon_opn
, MIN (CASE WHEN OFFC.WK_DAY ='MONDAY' THEN OFFC.OFFC_CLSNG_TIME END) AS mon_cls
, MIN (CASE WHEN OFFC.WK_DAY ='TUESDAY' THEN OFFC.OFFC_OPENG_TIME END) AS tue_opn
, MIN (CASE WHEN OFFC.WK_DAY ='TUESDAY' THEN OFFC.OFFC_CLSNG_TIME END) AS tue_cls
FROM GGDD.PROV_OFFC_HR OFFC
WHERE OFFC.PROV_ID = '0000600'
GROUP BY offc.prov_id
;This assumes there is (at most) only one row in the table for each distinct prov_id and weekday. If not, what do you want to do? Post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
The staement above works in Oracle 8.1 and up, but there's a better way (SELECT ... PIVOT) available in Oracle 11. What version are you using? (It's always a good idea to include this when you post a question.)
Edited by: Frank Kulash on Jan 6, 2011 8:22 PM -
Checking for the condition types using case statement
hi folks,
I have a lot of condition types that I have to check for and I am using case statement to do that. The code goes like this.
case wac-kschl.
when 'ZRAT' OR 'ZAGR' OR 'ZRCR' OR
'Y098' OR 'Y007' OR 'ZREW' OR 'Y106' OR 'ZTSR' OR 'Y127' OR 'Y125' OR 'Y126' OR 'Y124' OR 'Y157' OR 'Y092' OR 'Y085' OR 'Y090' OR 'ZMZD'
OR 'Y215' OR 'Y214' OR 'Y111' OR 'ZC$D' OR 'ZAUD'.
up till here it is working on errors and when I add few more condition types to the case statement it is throwing the error.
I have to check for all the condition types out here.
How can I correct it? Is there a better way to do it?
thanks
SanthoshHi Santhosh,
I think that your CASE statement has a flaw. The line length of one of the lines is too large. You need to insert a carriage-return to shorten it (or press the button 'Pretty Printer').
The code would look nicer like this:[code] CASE wac-kschl.
WHEN 'ZRAT' OR 'ZAGR' OR 'ZRCR' OR 'Y098' OR 'Y007' OR 'ZREW'
OR 'Y106' OR 'ZTSR' OR 'Y127' OR 'Y125' OR 'Y126' OR 'Y124'
OR 'Y157' OR 'Y092' OR 'Y085' OR 'Y090' OR 'ZMZD' OR 'Y215'
OR 'Y214' OR 'Y111' OR 'ZC$D' OR 'ZAUD' OR 'Z001' OR 'Z002'
OR 'Z003' OR 'Z004' OR 'Z005' OR 'Z006' OR 'Z007' OR 'Z008'
OR 'Z009' OR 'Z010' OR 'Z011' OR 'Z012' OR 'Z013' OR 'Z014'.
Do your thing here
WRITE: / 'OK'.
WHEN OTHERS.
WRITE: / 'NOT OK'.
ENDCASE.[/code]If this will not work for you, you could try a different approach:[code]* Local definition
DATA:
var_list(1024).
Build variable string for checking
CONCATENATE 'ZRAT ZAGR ZRCR Y098'
'Y007 ZREW Y106 ZTSR'
'Y127 Y125 Y126 Y124'
'Y157 Y092 Y085 Y090'
'ZMZD Y215 Y214 Y111'
'ZC$D ZAUD'
INTO var_list
SEPARATED BY space.
Check if the correct value is supplied
IF var_list CS wac-kschl.
Do your thing here
WRITE: / 'OK'.
ENDIF.[/code]Hope this helps you a bit.
Regards,
Rob. -
Using case statement in merge when matched
Hi,
I want to use case statement in the when matched clause of merge statement to ensure that I update only those fields that are undated.
create table TEST1
NAME1 VARCHAR2(25),
NAME2 VARCHAR2(25),
ID NUMBER not null
create table TEST2
ID NUMBER not null,
ID2 NUMBER not null,
NAME1 VARCHAR2(25),
NAME2 VARCHAR2(25)
merge into test1 t1
using
test2 t2
ON (t1.id = t2.id)
when matched
then
case
when t1.name1 != t2.name1
then
update set t1.name1 != t2.name1
when t1.name2 != t2.name2
then
update set t1.name2 != t2.name2
else
null;
end
it does not work and raises invalid sql command. Any idea how can I do that?
Thanks.
Sajid
Edited by: 808255 on Nov 12, 2010 4:22 AMHi
In that case you would have to use multiple statements and you may as well just use UPDATE instead of MERGE. Also, are you sure that you aren't trying to to fix a problem that doesn't actually exist.
Think about where the execution time is going to come from...
I would be tempted to do 1 UPDATE like this...
UPDATE test1 t1
SET (t1.name1,
t1.name2) = (SELECT t2.name1,
t2.name2
FROM test2 t2
WHERE t1.id = t2.id
AND (t1.name1 != t2.name1
OR t1.name2 != t2.name2))If you get specific performance issue with this, then post an explain plan and trace and I'll have a look.
I don't this the cost of the update is going to be as great as you think.
Cheers
Ben -
How to use CASE statement in WDA
Hi All,
Can any one Please expain me ' How to use CASE statement in Web dynpro ABAP? '
Please give me an example also.
Thanks in Advance !Hi,
The usage of case statement in webdynpro is same as used in general ABAP.
Data: l_id type string.
l_id = wdevent->get_string( 'ID' ).
case l_id.
when 'BTN1'.
when 'BTN2'.
when 'OTHERS'.
endcase.
Regards,
Radhika. -
Query Tuning - using CASE statement in the WHERE clause - Duplicate Post
Duplicate Post by mistake.
Please check
Query Tuning - using CASE statement in the WHERE clause
Edited by: Chaitanya on Jun 9, 2011 2:45 AM
Edited by: Chaitanya on Jun 9, 2011 2:46 AMDuplicate Post by mistake.
Please check
Query Tuning - using CASE statement in the WHERE clause
Edited by: Chaitanya on Jun 9, 2011 2:45 AM
Edited by: Chaitanya on Jun 9, 2011 2:46 AM -
Sql proposed to use case statement
Hi All
Can anyone help me here
This code works fine,here inthe inner sub queries(b,c,d,e,f),i am getting the weekly counts of usage data from the table mf_wer_OBI_USAGE_reqq.
As this is hitting same table with the similar set of queries so i was adviced to use case statement by taking the wk_1...5 in variable and making the query better
I am unable to figure out how to proceed.
Appreciate your help here.
Thanks
create table mf_wer_OBI_USAGE_reqq_WK
as select x.user_name id,x.mon MONTH_COUNT,x.wk_1 WEEK1_COUNT,x.wk_2 WEEK2_COUNT,x.wk_3 WEEK3_COUNT,x.wk_4 WEEK4_COUNT,x.wk_5 WEEK5_COUNT,x.subject_area_name,
y.EMP_FIRST_NAME FIRSTNAME,y.EMP_LAST_NAME SURNAME,y.E_MAIL_ADDRESS USER_MAILID,y.ouc OUC
from (select a.user_name,a.mon,a.subject_area_name,b.wk_1,c.wk_2,d.wk_3,e.wk_4,f.wk_5
from (select user_name,sum(count_us_st) mon,subject_area_name from mf_wer_OBI_USAGE_reqq group by user_name,subject_area_name) a,
(select user_name,sum(count_us_st) wk_1,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 1 and 7
group by user_name,subject_area_name) b,
(select user_name,sum(count_us_st) wk_2,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 8 and 14
group by user_name,subject_area_name) c,
(select user_name,sum(count_us_st) wk_3,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 15 and 21
group by user_name,subject_area_name) d,
(select user_name,sum(count_us_st) wk_4,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 22 and 28
group by user_name,subject_area_name) e,
(select user_name,sum(count_us_st) wk_5,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 29 and 31
group by user_name,subject_area_name) f
where a.user_name=b.user_name(+)
and a.subject_area_name=b.subject_area_name(+)
and a.user_name=c.user_name(+)
and a.subject_area_name=c.subject_area_name(+)
and a.user_name=d.user_name(+)
and a.subject_area_name=d.subject_area_name(+)
and a.user_name=e.user_name(+)
and a.subject_area_name=e.subject_area_name(+)
and a.user_name=f.user_name(+)
and a.subject_area_name=f.subject_area_name(+)) x,
dm_employee y
where x.user_name=y.id and
y.active_flg='Y';Swas_fly wrote:
This code works fineIf it's fine, why try to fix it?
Post your table (only the relevant columns as a CREATE TABLE statement) and some sample data (INSERT into) and your required output.
Post your code between these tags: -
Hi
I have two tables
employee
empid empname empaddress valid
Employeedetails
empid empname manager
I would like to validate empname from both the tables using case statement and empid as join and update 'valid' column in employee table to y/n.
Please help me with the syntaxHi,
Depending on your requirements:
UPDATE employee e
SET valid = (
SELECT CASE
WHEN COUNT (*) = 0
THEN 'n'
ELSE 'y'
END
FROM employeedetails
WHERE empname = e.empname
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
If you're asking about a DML statement, such as UPDATE, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
Using Case statement instead of IF in formula fields
Hi,
Can I use Case statement instead of IF in formula fields?If yes,please specify the syntax.
regards,
sunithaHi Sunitha,
You can surely use case statement instead of the If statement. The syntax for the case statement is :
Select [1 To n]
Case "Condition a", "Condition b":
"c"
Case "Condition d","Condition e":
"f"
Default:
Hope this helps you!
Regards,
Anindita -
Can I use case statements in triggers?
I created this trigger, it works BUT I don't like those parentheses at the begining, I would like
to change those parentheses for case statements, well that is my question, can you use case statements in triggers, how you would translate the following in case statement?
FOR EACH ROW
WHEN ( (new.sgbstdn_levl_code = 'UG')
and
( (NEW. SGBSTDN_STST_CODE NOT IN ('GR','SA','AS','IS') )
OR
( (NEW. SGBSTDN_STST_CODE = 'IS' ) AND
(NEW. SGBSTDN_STYP_CODE IN ('N' , 'T' )) AND
(OLD. SGBSTDN_STST_CODE = 'AS' ) ) ) )
==================================================================================================
CREATE OR REPLACE TRIGGER CC_STUD_WITHDRAWAL
AFTER UPDATE OR INSERT ON SATURN . SGBSTDN
FOR EACH ROW
WHEN ( (new.sgbstdn_levl_code = 'UG')
and
( (NEW. SGBSTDN_STST_CODE NOT IN ('GR','SA','AS','IS') )
OR
( (NEW. SGBSTDN_STST_CODE = 'IS' ) AND
(NEW. SGBSTDN_STYP_CODE IN ('N' , 'T' )) AND
(OLD. SGBSTDN_STST_CODE = 'AS' ) ) ) )
DECLARE
v_params gokparm.t_parameterlist;
event_code gtveqnm.gtveqnm_code%TYPE;
firstname spriden.spriden_first_name%TYPE;
lastname spriden.spriden_last_name%TYPE;
middlename spriden.spriden_mi%TYPE;
id spriden.spriden_id%TYPE;
CURSOR get_stud_name IS
SELECT
spriden_id ,
spriden_last_name ,
spriden_first_name ,
spriden_mi
FROM
saturn.spriden
WHERE spriden_pidm = :NEW.SGBSTDN_PIDM
AND spriden_change_ind IS NULL;
BEGIN
IF goksyst . f_isSystemLinkEnabled ( 'WORKFLOW' ) THEN
event_code := SUBSTR ( gokevnt.F_CheckEvent ( 'WORKFLOW' ,'CC_STUDENT_WITHDRAW' ),1,20);
OPEN get_stud_name ;
FETCH get_stud_name INTO id , lastname , firstname , middlename ;
CLOSE get_stud_name ;
----pass parameters to the event
v_params ( 1 ).param_value := 'CC_STUDENT_WITHDRAW' ;
v_params ( 2 ).param_value := '' ;
v_params ( 3 ).param_value := 'Student Withdrawal:' || lastname || ',' || firstname || ' ' ||
middlename ;
v_params ( 4 ).param_value := :NEW.sgbstdn_pidm ;
v_params ( 5 ).param_value := id ;
v_params ( 6 ).param_value := lastname ;
v_params ( 7 ).param_value := firstname ;
v_params ( 8 ).param_value := middlename ;
v_params ( 9 ).param_value := :NEW.sgbstdn_term_code_eff ;
v_params ( 10 ).param_value := :NEW.SGBSTDN_STST_CODE ;
v_params ( 11 ).param_value := :NEW.SGBSTDN_STYP_CODE ;
gokparm.Send_Param_List ( event_code , v_Params );
END IF;
END;
/You could delete a fair number of extraneous parentheses.
CREATE OR REPLACE TRIGGER cc_stud_withdrawal
AFTER UPDATE OR INSERT
ON saturn.sgbstdn
FOR EACH ROW
WHEN NEW.sgbstdn_levl_code = 'UG'
AND ( NEW.sgbstdn_stst_code NOT IN ('GR', 'SA', 'AS', 'IS')
OR ( NEW.sgbstdn_stst_code = 'IS'
AND NEW.sgbstdn_styp_code IN ('N', 'T')
AND OLD.sgbstdn_stst_code = 'AS')) -
Conditional Filters using case statements
Hello,
I have a table view which displays Total Quota and Theatre Quota. Against the Total Quota, there are 2 values - Rollover Revenue and Theatre Revenue. Against the Theatre Quota, there is only Theatre Revenue.
What I want to accomplish is to display only the Rollover Revenue Aggregated Quarterly number whenever there is a Total Quota number and not display the Theatre Revenue number
In the table view,
Year Name Quarter Name Quarter Name Sort Person Region Quota Name Quarterly Quota Credit Amount QTD Attainment Credit Type Name
YEAR-2012 QTR-1-2012 QTR-1-2012 750 Total Quota 6,128,500 5,492,081 89.62% Rollover Revenue Aggregated Quarterly
750 6,128,500 5,344,000 87.20% Theatre Revenue
QTR-2-2012 QTR-2-2012 750 Total Quota 5,922,500 5,890,264 99.46% Rollover Revenue Aggregated Quarterly
750 5,922,500 6,120,000 103.33% Theatre Revenue
QTR-3-2012 QTR-3-2012 750 Total Quota 5,716,500 0 0.00%
QTR-4-2012 QTR-4-2012 750 Total Quota 5,510,500 0 0.00%
I used an example in the following link:
http://oraclebizint.wordpress.com/2008/02/06/oracle-bi-ee-101332-conditional-filters-using-case-statements-in-filters/
and applied the example in my scenario:
CASE WHEN Quota."Quota Name" = 'Total Quota' THEN "Credit Type"."Credit Type Name" ELSE 'Dummy' END != 'Theatre Revenue'
I still get duplicate rows.
Thanks.Could you suggest any solutions for this problem where I can conditionally hide the number only for a certain type of data and not for all type of data?
Thanks. -
SSIS: Using CASE Statement Within A Derived Column Transformation Expression
The following is my Data Flow:
Ole DB Source > Copy Column > Derived Column >Ole DB Command
My OLE DB Source has the following SQL command task:
SELECT *
FROM Repair R
LEFT OUTER JOIN Vehicle V
ON R.SN = V.SN
AND R.Reg = V.Reg
LEFT OUTER JOIN Product P
ON R.PID = P.PID
This yields a column of concern for me named PartNumber, which are represented by the following 2 formats:
The following are my Copied Columns:
Input Column = PartNumber
Output Alias = Copy of PartNumber
The following are my Derived Column expressions:
Derived Column Name Derived Column Expression
Name Replace 'PartNumber' LEFT(PartNumber,FINDSTRING(PartNumber,"-",1) - 1)
Copy of Name Replace 'Copy of PartNumber' RIGHT([Copy of PartNumber],LEN([Copy of PartNumber]) - FINDSTRING([Copy of PartNumber],"-",1))
So My PartNumber Column is Replaced with ######### of type
string and the Copy of PartNumber column is replaced with
#### of type int
As I stated earlier PartNumber also is in the format of %-%-% which raises the following question:
How can I replace PartNumber Column with NULL if in format of
%-%-% and take the PartNumber and put it in new column named
SubPart while keeping all the logic within SSIS objects?
So in essence I want to do something like the following:
PartNumber = CASE
WHEN 'PartNumber' LIKE '%-%-%'
THEN ABC = PartNumber AND PartNumber IS NULL
END
I have tried the case statement in a Derived Column expression and is not working. Would I add the
CASE statement to the SQL command task in my OLE DB Source?
I hope this question is concise for you.If it must be in SSIS, I would put a derived column stage earlier in the process to do my check for me. Then in the second derived column stage do the check against each output column (part, subpart, copy of part) to decide which way it goes
PS Not sure if it's a 2012 function but SSIS has a function called TOKEN that will allow you to pull your subparts for you rather than the left/right you are doing -
I am trying to use a case statement in an OWB mapping. I am attempting to use it in expression builder within a filter object. Each time I try to validate the expression in the expression builder I get an error:
Line 4, Col 6:
PL/SQL: ORA-00920: invalid relational operator
Below is the code used in the expression builder window:
CASE A.ATTRIBUTE_NAME
WHEN 'CA COMPLETION DATE' THEN RTRIM(A.C_CODE_VALUE)
ELSE NULL
END
Any help with what is happening would be appreciated.
Thank you.
MattThank you both for you help. I initially tried to use the expression operator but was confused since the expression builder in the expression operator has the drop down list with the available SQL clauses greyed out. In the OWB documentation it states that the drop down will contain SQL clauses that are appropriate for that expression type so when I saw it was greyed out I assumed that those clauses where not valid for this operator. Sure enough though when I pasted in my Case statement it verified correctly.
Thanks again,
Matt -
Using Case statement to insert,update,delete the tables
Hi All,
I have to check the databse ,
if it is developement then
insert/update/delete values in tables;
if it staging then
insert/update/delete values in tables;
if it is production then
insert/update/delete values in tables;
thers is function available to check the current database
For doing the about i am trying to write CASE statement like this
SELECT function,
case
when fun = 'developement' then insert into table1 values ('abcd','1234')
when fun = 'staging' then insert into table1 values ('abcd','1234')
when fun= 'production' then insert into table1 values ('abcd','1234')
else null
from dual
its throughing me an error
please help
Thanks,Hi,
You can use CASE staement any place where an expression is expected.
For example, in:
UPDATE table_a
SET col1 = exp1
, col2 = exp2
WHERE exp3 = exp4;all the expressions are labled lke expn.
Note that table_a, col1 and col2 are not expressions: you must hard-code these names, or use dynamic SQL.
So it's okay to say:
UPDATE table_a
SET col1 = CASE
WHEN db = 'development' THEN 0
WHEN db = 'staging' THEN 1
END
, col2 = CASE
WHEN db = 'development' THEN NULL
WHEN db = 'staging' THEN col2
END
WHERE db != 'production';In this example:
in the development database, col1 is set to 0 and col2 is set to NULL
in the staging database, col1 is set to 1 and col2 is unchanged (that is, set to what it already was)
in the production database, nothing is changed (the WHERE condition is always FALSE) -
Query Tuning - using CASE statement in the WHERE clause
Hi All,
My query has been modified to use a CASE statement in the WHERE clause to consider data from certain columns based on a parameter value. This modified query is doing a full table scan and running endlessly. Please suggest what may be done to improve its performance:
Query:
SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
os.acctnum,
os.avieworigin_refid,
COUNT(1) cnt_articleview,
SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
FROM TABLE1 os
WHERE os.acctnum IS NOT NULL
AND os.avieworigin_refid IS NOT NULL
AND os.requestdatetime IS NOT NULL
AND UPPER(os.success_ind) = 'S'
AND CASE WHEN
Param_ValueToCheck = 'FULL' AND get_date_timestamp(os.requestdatetime) BETWEEN
TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
THEN 1
WHEN
Param_ValueToCheck = 'INCR' AND os.entry_createddate BETWEEN
TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
THEN 1
END = 1
AND CASE WHEN
Param_ValueToCheck = 'FULL' AND os.entry_CreatedDate BETWEEN
TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
THEN 1
WHEN
Param_ValueToCheck = 'INCR' THEN 1
END = 1
GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;Table Description:
(Number of rows : approx > 600,000,000)
Name Null Type
ARTICLEID NOT NULL NUMBER(20)
USERKEY NUMBER(10)
AVIEWORIGIN_REFID VARCHAR2(10)
SUCCESS_IND VARCHAR2(2)
ENTRY_CREATEDDATE DATE
CREATED_BY VARCHAR2(10)
FILENUMBER NUMBER(10)
LINENUMBER NUMBER(10)
ACCTNUM VARCHAR2(10)
AUTOCOMPLETEDTERM NUMBER(2)
REQUESTDATETIME VARCHAR2(19)Explain Plan
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 2224314832
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 590 | 33040 | 2501K (1)| 08:20:15 | | |
| 1 | HASH GROUP BY | | 590 | 33040 | 2501K (1)| 08:20:15 | | |
| 2 | PARTITION RANGE ALL| | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575|
|* 3 | TABLE ACCESS FULL | TABLE1 | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575|
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE WHEN ('FULL'='FULL' AND
"OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN
'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE WHEN ('FULL'='FULL'
AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00',
'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE('
2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
PLAN_TABLE_OUTPUT
2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND
"OS"."AVIEWORIGIN_REFID" IS NOT NULL)Edited by: Chaitanya on Jun 9, 2011 2:44 AM
Edited by: Chaitanya on Jun 9, 2011 2:47 AMHi Dom,
Modified Query:
SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
os.acctnum,
os.avieworigin_refid,
COUNT(1) cnt_articleview,
SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
FROM TABLE1 os
WHERE os.acctnum IS NOT NULL
AND os.avieworigin_refid IS NOT NULL
AND os.requestdatetime IS NOT NULL
AND UPPER(os.success_ind) = 'S'
AND (('FULL' = 'FULL'
AND (get_date_timestamp(os.requestdatetime) BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND os.entry_CreatedDate BETWEEN TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
OR ('FULL' = 'INCR'
AND os.entry_createddate BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') ))
GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;Execute Plan:
PLAN_TABLE_OUTPUT
Plan hash value: 3615447714
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 25125 | 1374K| | 407K (1)| 01:21:36 | | |
| 1 | HASH GROUP BY | | 25125 | 1374K| 3768K| 407K (1)| 01:21:36 | | |
| 2 | PARTITION RANGE ITERATOR| | 25125 | 1374K| | 407K (1)| 01:21:32 | 29 | 31 |
|* 3 | TABLE ACCESS FULL | TABLE1 | 25125 | 1374K| | 407K (1)| 01:21:32 | 29 | 31 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - filter("OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
UPPER("OS"."SUCCESS_IND")='S' AND "OS"."REQUESTDATETIME" IS NOT NULL AND
"ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"OS"."ACCTNUM" IS NOT NULL AND "OS"."AVIEWORIGIN_REFID" IS NOT NULL AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))Edited by: Chaitanya on Jun 9, 2011 4:51 AM
Maybe you are looking for
-
Application Supersedence not working as I want and expect!
Hello, I need help to find out how to properly deploy an upgraded application using the SCCM 2012 Application supersedence. What I have One application in production with version 1.0. Let us call it APPL-BLUE1.0 New application of the same product wi
-
Suddenly, I can no longer print playlists for CD jewelcase inserts. I've been printing these with no problem for months and yesterday for the first time, when I select 'print' from the file menuj I get a message saying, " printing of jobs for this pr
-
Hello Friends, I have to map the following scenario. Please advise the config & master data. 1) My sample size should change if my acceptance & rejecetion level changes. 2) If rejection increases then the sample size in the next lot should increase &
-
PCUI Application Not Found eRROR
I would like to use the PCUI, so I was advised to go to transaction se80 select BSP Application from the drop down,type in CRM_BSP_FRAME, click the display button and then click on Pages with Flow Logic. Right click on select.htm and click on test. T
-
How does the info like phone number, callerid pass from CCA to Virtual CTI driver and Siebel. Apart from configuring the drivers and profiles, driver parameters and events, commands does this require to write any script to pass the values when the ag