Help in modifying the query
When i run the following query,
select row_wid,
case when X_ACT_TYPE in ('Install','3Ph Batt Replacement') then 'FLAG_1'
when (x_act_type ='Maintenance' and X_act_subtype = 'Break Fix') then 'FLAG_2'
When (x_act_type ='Maintenance' and X_act_subtype = 'Preventive Maintenance') then 'FLAG_3'
else 'FLAG_4' end as FLAG_TYPE
from anl_crm_rmw.wc_activity_d
my value for flag_type is always Flag_4. It is not able to find other types.
Is there any problem in query. Pls guide me.
I am getting the following error ORA-00933, when i use the following query,
select a.row_wid,
case when a.X_ACT_TYPE = 'Install' then 'FLAG_1'
when a.X_ACT_TYPE = '3Ph Batt Replacement' then 'FLAG_1'
when a.X_ACT_TYPE = 'Customer Training' then 'FLAG_1'
when a.X_ACT_TYPE = 'Product Substuition' then 'FLAG_1'
when a.X_ACT_TYPE = 'Customer Commercial Support' then 'FLAG_1'
when (a.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break Fix') then 'FLAG_2'
when (a.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break/Fix') then 'FLAG_2'
when (a.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break Fix/Corrective Maint') then 'FLAG_2'
when (a.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break Fix-Corrective Maint') then 'FLAG_2'
When (a.x_act_type = 'Maintenance' and a.X_act_subtype = 'Preventive Maintenance') then 'FLAG_3'
When (a.x_act_type = 'Maintenance' and a.X_act_subtype = 'System Removal') then 'FLAG_3'
When (a.x_act_type = 'Maintenance' and a.X_act_subtype = 'Standby') then 'FLAG_3'
else 'FLAG_4' end as FLAG_TYPE,
C.wrnty_end_dt
from anl_crm_rmw.wc_activity_d A,
anl_crm_rmw.wc_activity_F B,
anl_crm_rmw.w_asset_d C
where A.ROW_WID = B.ROW_WID
and B.ASSET_WID = C.ROW_WID
and a.row_wid = 2088219
group by A.row_wid, case when A.X_ACT_TYPE = 'Install' then 'FLAG_1'
when A.X_ACT_TYPE = '3Ph Batt Replacement' then 'FLAG_1'
when A.X_ACT_TYPE = 'Customer Training' then 'FLAG_1'
when A.X_ACT_TYPE = 'Product Substuition' then 'FLAG_1'
when A.X_ACT_TYPE = 'Customer Commercial Support' then 'FLAG_1' end
when (A.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break Fix') then 'FLAG_2'
when (A.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break/Fix') then 'FLAG_2'
when (A.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break Fix/Corrective Maint') then 'FLAG_2'
when (A.x_act_type = 'Maintenance' and a.X_act_subtype = 'Break Fix-Corrective Maint') then 'FLAG_2'
When (A.x_act_type = 'Maintenance' and a.X_act_subtype = 'Preventive Maintenance') then 'FLAG_3'
When (A.x_act_type = 'Maintenance' and a.X_act_subtype = 'System Removal') then 'FLAG_3'
When (A.x_act_type = 'Maintenance' and a.X_act_subtype = 'Standby') then 'FLAG_3'
else 'FLAG_4' end
Similar Messages
-
VO Extension Error in modifying the query of XML Publisher Report Template
Hi Friends,
I have one requirement related to calling XML Publisher Reports Template from OAF Page.
When clicking on the submit button the XML Publisher template is calling and displaying the data.
Our requirement is to display some more columns in the XML Publisher Template and display the data.
As according to OAF stndards,whenever we need to add new columns for display or SELECT purpose,
we will do the VO Extension. So we modified the query by adding the new additional colums in the standard VO.
I am able to retrieve the data from the SQL DEVELOPER. But when doing the VO Extension process and
calling the template from the OAF page its throwing the following error.Please suggest me some alternatives
to fix the issue.
oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT
DECODE(ASO_QUOTES.RESOURCE_ID, null, sales.name, sales1.name) sales_rep_name,
aso_quotes.quote_name,
aso_quotes.contract_id,
aso_quotes.quote_number||decode(aso_quotes.quote_version,NULL,'',' - ') || aso_quotes.quote_version quote_name_version,
to_char(aso_quotes.quote_expiration_date, nvl(FND_PROFILE.VALUE('ICX_DATE_FORMAT_MASK'), 'DD-MON-RRRR')) quote_expiration_date,
TO_NUMBER(TO_CHAR(aso_quotes.quote_expiration_date,'J')) - TO_NUMBER(TO_CHAR(Sysdate,'J')) duration,
I_HEADER_CONTACT_PARTY.PARTY_NAME sold_to_contact_name,
I_CUST_PARTIES.party_name customer_name,
I_PHONE.PHONE_AREA_CODE || DECODE(I_PHONE.PHONE_AREA_CODE , NULL, '',' ' ) || I_PHONE.PHONE_NUMBER full_phone_number,
I_INVOICE_REL_PARTY.PARTY_NAME invoice_to_contact_name,
I_ACCTS_INV_PARTY.PARTY_NAME invoice_to_cust_party_name,
I_INVOICE_LOCATIONS.ADDRESS1 invoice_to_address1,
I_INVOICE_LOCATIONS.ADDRESS2 invoice_to_address2,
I_INVOICE_LOCATIONS.ADDRESS3 invoice_to_address3,
I_INVOICE_LOCATIONS.ADDRESS4 invoice_to_address4,
decode(I_INVOICE_LOCATIONS.city, null,'',I_INVOICE_LOCATIONS.city || decode(I_INVOICE_LOCATIONS.county,null,'',',' || I_INVOICE_LOCATIONS.county)) invoice_to_city,
I_INVOICE_LOCATIONS.state || decode(I_INVOICE_LOCATIONS.postal_code, null,'',' '||
I_INVOICE_LOCATIONS.postal_code || decode(I_INVOICE_LOCATIONS.province,null,'',',' ||I_INVOICE_LOCATIONS.province )) invoice_to_county,
I_INVOICE_LOCATIONS.country invoice_to_country,
aso_quotes.currency_code Currency_Code,
(select distinct ppf.email_address
from per_people_f ppf,
JTF_RS_SALESREPS jrs
where jrs.resource_id = aso_quotes.resource_id
and jrs.PERSON_ID = ppf.person_id
and ppf.person_type_id = 3
) Sales_Rep_Email,
aso_quotes.quote_header_id, oav.name||decode(oav.agreement_num,NULL,'',',')||oav.agreement_num||decode(oav.agreement_num,NULL,'',',')||oav.revision Agreement_name,
oav.name||oav.agreement_num||oav.revision Agreement_check,
to_char(oav.revision_date, nvl(FND_PROFILE.VALUE('ICX_DATE_FORMAT_MASK'), 'DD-MON-RRRR')) revision_date,
(select payment_term_name
FROM
aso_payments_v
WHERE
quote_line_id is null and
quote_header_id = aso_quotes.quote_header_id) payment_terms,
to_char(sysdate, nvl(FND_PROFILE.VALUE('ICX_DATE_FORMAT_MASK'), 'DD-MON-RRRR')) curr_date,
aso_quotes.total_list_price total_list_price,
aso_quotes.total_adjusted_amount total_adjusted_amount,
(aso_quotes.total_list_price + aso_quotes.total_adjusted_amount) total_net_price,
aso_quotes.total_shipping_charge charges_total,
aso_quotes.total_tax taxes_total,
aso_quotes.total_quote_price total_quote_price,
(select cust_po_number
FROM
aso_payments
WHERE
quote_line_id is null and
quote_header_id = aso_quotes.quote_header_id ) cust_po_number,
(select fct.name
from fnd_currencies_tl fct
where aso_quotes.currency_code = fct.currency_code
and fct.language = userenv('lang')) Currency_Name,
(select fcurr.symbol
from fnd_currencies fcurr
where aso_quotes.currency_code = fcurr.currency_code) Currency_Symbol,
(Select meaning
From oe_lookups
Where lookup_type = 'FREIGHT_TERMS'
And lookup_code = (select aship.freight_terms_code
from aso_shipments aship
where aship.quote_header_id = aso_quotes.quote_header_id
and aship.quote_line_id is null)) Freight_Terms,
(Select fl.meaning
From fnd_lookup_values fl
where fl.lookup_type = 'SHIP_METHOD'
And fl.lookup_code = (select aship.ship_method_code
from aso_shipments aship
where aship.quote_header_id = aso_quotes.quote_header_id
and aship.quote_line_id is null)
And fl.language = userenv('LANG')) shipping_method ,
aso_quotes.org_id ,
aso_quotes.quote_number ,
aso_quotes.Quote_version VersionNumber,
I_ACCTS.ACCOUNT_NUMBER CustomerNumber,
oav.agreement_num Agreement_Number,
:action action,
aso_quotes.minisite_id minisite_id,
(select imt.msite_name from ibe_msites_tl imt where imt.msite_id = aso_quotes.minisite_id
and imt.language = userenv('LANG')) msite_name,
(select asl.meaning from oe_lookups asl, aso_shipments ash
where asl.lookup_type = 'SHIPMENT_PRIORITY'
and asl.lookup_code = ash.shipment_priority_code
and ash.quote_header_id = aso_quotes.quote_header_id) shipment_priority_name
,(select OE_SYS_PARAMETERS.VALUE('INSTALLMENT_OPTIONS',aso_quotes.org_id) from dual) enable_pay_now
from
hz_CONTACT_POINTS I_PHONE ,
HZ_RELATIONSHIPS I_HEADER_CONTACT_REL,
HZ_PARTIES I_HEADER_CONTACT_PARTY,
ASO_QUOTE_HEADERS ASO_QUOTES,
HZ_RELATIONSHIPS I_INVOICE_REL,
HZ_PARTIES I_INVOICE_REL_PARTY,
HZ_PARTY_sites I_INVOICE_PARTY_SITES,
HZ_LOCATIONS I_INVOICE_LOCATIONS,
HZ_PARTIES I_CUST_PARTIES,
HZ_CUST_ACCOUNTS I_ACCTS,
HZ_CUST_ACCOUNTS I_ACCTS_INV,
HZ_PARTIES I_ACCTS_INV_PARTY,
JTF_RS_SALESREPS_MO_V SALES,
JTF_RS_SALESREPS_MO_V SALES1,
FND_TERRITORIES_VL I_TERRITORIES,
oe_agreements_vl oav
where
ASO_QUOTES.PARTY_ID = I_HEADER_CONTACT_REL.PARTY_ID(+)
AND I_HEADER_CONTACT_REL.SUBJECT_ID = I_HEADER_CONTACT_PARTY.PARTY_ID(+)
AND I_HEADER_CONTACT_REL.SUBJECT_TYPE(+) = 'PERSON'
AND I_HEADER_CONTACT_REL.SUBJECT_TABLE_NAME(+) = 'HZ_PARTIES'
and i_header_contact_rel.object_id(+) = aso_quotes.cust_party_id
AND ASO_QUOTES .INVOICE_TO_PARTY_SITE_ID = I_INVOICE_PARTY_SITES.PARTY_SITE_ID (+)
AND I_INVOICE_PARTY_SITES.LOCATION_ID = I_INVOICE_LOCATIONS.LOCATION_ID(+)
AND I_INVOICE_LOCATIONS.country = I_TERRITORIES.territory_code(+)
AND ASO_QUOTES.INVOICE_TO_PARTY_ID = I_INVOICE_REL.PARTY_ID(+)
AND I_INVOICE_REL.SUBJECT_ID = I_INVOICE_REL_PARTY.PARTY_ID(+)
AND I_INVOICE_REL.SUBJECT_TYPE(+) = 'PERSON'
AND I_INVOICE_REL.SUBJECT_TABLE_NAME(+) = 'HZ_PARTIES'
AND i_invoice_rel.object_id (+) = aso_quotes.invoice_to_cust_party_id
AND ASO_QUOTES.ORG_ID = SALES.ORG_ID(+)
AND ASO_QUOTES.EMPLOYEE_PERSON_ID = SALES.PERSON_ID (+)
AND ASO_QUOTES.ORG_ID = SALES1.ORG_ID (+)
AND ASO_QUOTES.RESOURCE_ID = SALES1.RESOURCE_ID (+)
AND ASO_QUOTES.CUST_ACCOUNT_ID =I_ACCTS.CUST_ACCOUNT_ID(+)
AND ASO_QUOTES.CUST_PARTY_ID = I_CUST_PARTIES.PARTY_ID
AND ASO_QUOTES.INVOICE_TO_CUST_ACCOUNT_ID = I_ACCTS_INV.CUST_ACCOUNT_ID(+)
AND ASO_QUOTES.INVOICE_TO_CUST_PARTY_ID = I_ACCTS_INV_PARTY.PARTY_ID(+)
AND aso_quotes.phone_id = i_phone.contact_point_Id(+)
AND oav.agreement_id(+) = aso_quotes.contract_id
AND aso_quotes.quote_header_id = 666584
at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:912)
at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:886)
at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(OAException.java:1009)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:211)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:762)
at oracle.apps.aso.print.webui.MainCO.processRequest(MainCO.java:180)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:600)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean.processRequest(OAHeaderBean.java:391)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean.processRequest(OAStackLayoutBean.java:350)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1182)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2607)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1940)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:543)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:431)
at OA.jspService(_OA.java:212)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:259)
at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:51)
at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:284)
at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:395)
at OA.jspService(_OA.java:221)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:619)
## Detail 0 ##
java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: 1
at oracle.jdbc.driver.OraclePreparedStatement.setObjectAtName(OraclePreparedStatement.java:11915)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObjectAtName(OraclePreparedStatementWrapper.java:815)
at oracle.jbo.server.OracleSQLBuilderImpl.bindParamValue(OracleSQLBuilderImpl.java:3919)
at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3335)
at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:13827)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:804)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:669)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3723)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4560)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:743)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:892)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:806)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:800)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3643)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(OAViewObjectImpl.java:439)
at oracle.apps.aso.print.server.PrintQuoteAMImpl.queryQuote(PrintQuoteAMImpl.java:447)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:762)
at oracle.apps.aso.print.webui.MainCO.processRequest(MainCO.java:180)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:600)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean.processRequest(OAHeaderBean.java:391)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean.processRequest(OAStackLayoutBean.java:350)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1182)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2607)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1940)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:543)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:431)
at OA.jspService(_OA.java:212)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:259)
at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:51)
at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:284)
at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:395)
at OA.jspService(_OA.java:221)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:619)
java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: 1
at oracle.jdbc.driver.OraclePreparedStatement.setObjectAtName(OraclePreparedStatement.java:11915)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObjectAtName(OraclePreparedStatementWrapper.java:815)
at oracle.jbo.server.OracleSQLBuilderImpl.bindParamValue(OracleSQLBuilderImpl.java:3919)
at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3335)
at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:13827)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:804)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:669)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3723)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4560)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:743)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:892)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:806)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:800)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3643)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(OAViewObjectImpl.java:439)
at oracle.apps.aso.print.server.PrintQuoteAMImpl.queryQuote(PrintQuoteAMImpl.java:447)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:762)
at oracle.apps.aso.print.webui.MainCO.processRequest(MainCO.java:180)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:600)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean.processRequest(OAHeaderBean.java:391)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean.processRequest(OAStackLayoutBean.java:350)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1182)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:968)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:935)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:659)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:252)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2607)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1940)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:543)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:431)
at OA.jspService(_OA.java:212)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:259)
at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:51)
at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:284)
at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:395)
at OA.jspService(_OA.java:221)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:619)"java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL"
Try the suggestions in this? https://kr.forums.oracle.com/forums/thread.jspa?messageID=10253362
Check the bindign styles and bind variables.. -
Need help in refining the query
Hello Experts,
Need your help in refining the query further more.
table structure
Mskey Col A Col B
1 empno [20141127-20151128]1234
1 empno [20151201-99991231]232544
1 salutation [20141127-99991231]Mrs
1 salutation [20151127-99991231]Mr
2 empno [20141127-20151128]1234
2 empno [20151201-99991231]232544
2 salutation [20141127-99991231]Mrs
2 salutation [20151127-99991231]Mr
My requirement is to find the list of overlapping records based on the dates
user details may be varying from time to time as new data would be pushed through HR systems to identity store via an interface.
The job is getting failed whenever there is any overlapping with dates. So we proactively decided to schedule a job in this regards which runs weekly and would let us know for which and all the users there is overlapping dates are there, so that we can send the list to HR team for pushing new data.
Overlapping Issue Example:
The users employee id for an year it is 1234 and later he moved to another department and his employee id got changed and it became 2345 remaining all details are same. So the HR systems send the data for this user as empno - [20141127-20151128]1234 and empno - [20151201-99991231]232544
it means from 20141127 to 20151128 his employee no is 1234 and from 20151201 to 99991231 his employee would be 2345.
This is a correct case and the tool would accept this data.
the below cases are invald
Case 1: 1 salutation [20141127-99991231]Mrs 1 salutation [20151127-99991231]Mr
Case 2: 2 salutation [20141127-99991231]Mrs 2 salutation [20141127-99991231]Mr
So we wanted to find these overlapping records from tables.
My Query:
I am able to successfully write query for the case 2 type but unable to write for case1.
select id,colA
count(left(ColB,CHARINDEX(']',ColB))) as 'Count'
from tblA with (nolock)
where id in (Select distinct id from tblb with (nolock))
group by id, cola,left(ColB,CHARINDEX(']',ColB))
having count(left(ColB,CHARINDEX(']',ColB)))>1Finally got the required answer with the below query
WITH Cte AS
SELECT ID,ColA,ColB,ROW_NUMBER() OVER(ORDER BY (SELECT 1)) AS RN,
CAST(SUBSTRING(ColB,2,CHARINDEX('-',ColB)-2) AS DATE) AS StartDT,
CAST(SUBSTRING(ColB,CHARINDEX('-',ColB)+1,8) AS DATE) AS EndDT FROM TblA
SELECT c1.ID, c1.ColA,c1.ColB
FROM Cte c1 JOIN Cte c2
ON c1.RN != c2.RN
AND c1.ID=c2.ID
AND c1.ColA=c2.ColA
AND (c1.StartDT BETWEEN c2.StartDT AND c2.EndDT OR c2.StartDT BETWEEN c1.StartDT AND c1.EndDT ) -
Help to rewrite the query --performance issue
Hi ,
Please help to rewrite the query since it's performance is not good.Especially second inline query(CASE statements are therein select caluse ..)is taking more cost.
Database Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
SELECT *
FROM
(SELECT q.*,
COUNT(*) OVER() AS record_count,
ROWNUM AS row_num
FROM
(SELECT ExName.examiner_code,
examiner_name,
:v_year,
:v_month,
count_fb,
NVL(count_entered_fb, 0) count_entered_fb,
NVL(count_sent_fb, 0) count_sent_fb,
NVL(count_edited_fb, 0) count_edited_fb,
NVL(count_complete_fb, 0) count_complete_fb,
NVL(count_withibcardiff_fb, 0) count_withibcardiff_fb
FROM
(SELECT examiner_code,
COUNT(*) AS count_fb
FROM
(SELECT
examiner_code,
paper_code,
assessment_school
FROM
( SELECT DISTINCT ce.examiner_code,
ce.paper_code,
ce.assessment_school
FROM
(SELECT
DISTINCT assessment_school,
paper_code,
examiner_code
FROM candidate_examiner_allocation cea
WHERE cea.element = 'Moderation of IA'
AND cea.year = :v_year
AND cea.month = :v_month
) ce,
subject_group sg,
subject_component sc
WHERE (:v_padded_examiner_code IS NULL
OR ce.examiner_code = :v_padded_examiner_code)
AND (:v_subject_group IS NULL
OR sg.group_number = :v_subject_group)
AND sg.year = :v_year
AND sg.month = :v_month
AND sc.year = :v_year
AND sc.month = :v_month
AND sc.paper_code = ce.paper_code
AND sc.subject = sg.subject
AND sc.lvl = sg.lvl
AND (:v_subject IS NULL
OR sc.subject = :v_subject)
AND (:v_lvl IS NULL
OR sc.lvl = :v_lvl)
) ea
GROUP BY examiner_code
) ExName,
(SELECT examiner_code,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'ENTERED'
THEN 1
ELSE NULL
END) AS count_entered_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'SENT'
THEN 1
ELSE NULL
END) AS count_sent_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'EDITED'
THEN 1
ELSE NULL
END) AS count_edited_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'COMPLETE'
THEN 1
ELSE NULL
END) AS count_complete_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'WITH IBCARDIFF'
THEN 1
ELSE NULL
END) AS count_withibcardiff_fb
FROM ia_instances ia1,
workflow_instance wfi
WHERE wfi.instance_id = ia1.workflow_instance_id
AND ia1.year = :v_year
AND ia1.month = :v_month
GROUP BY ia1.year,
ia1.month,
examiner_code
) iaF,
(SELECT person_code,
title
|| ' '
|| firstname
|| ' '
|| lastname AS examiner_name
FROM person
WHERE :v_examiner_name IS NULL
OR UPPER(title
|| ' '
|| firstname
|| ' '
|| lastname) LIKE :v_search_examiner_name
) P
WHERE ExName.examiner_code = iaF.examiner_code (+)
AND ExName.examiner_code = p.person_code
ORDER BY ExName.examiner_code
) q
) rc
WHERE row_num >= :v_start_row
AND row_num <= (:v_start_row+(:v_max_row-1));explain plan
line 1: SQLPLUS Command Skipped: set linesize 130
line 2: SQLPLUS Command Skipped: set pagesize 0
PLAN_TABLE_OUTPUT
Plan hash value: 1581970599
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 276 | | 2187 (6)| 00:00:34 |
|* 1 | FILTER | | | | | | |
|* 2 | VIEW | | 1 | 276 | | 2187 (6)| 00:00:34 |
| 3 | WINDOW BUFFER | | 1 | 250 | | 2187 (6)| 00:00:34 |
| 4 | COUNT | | | | | | |
| 5 | VIEW | | 1 | 250 | | 2187 (6)| 00:00:34 |
| 6 | SORT ORDER BY | | 1 | 119 | | 2187 (6)| 00:00:34 |
| 7 | NESTED LOOPS | | 1 | 119 | | 2186 (6)| 00:00:34 |
|* 8 | HASH JOIN OUTER | | 1 | 92 | | 2185 (6)| 00:00:34 |
| 9 | VIEW | | 1 | 20 | | 51 (4)| 00:00:01 |
| 10 | SORT GROUP BY | | 1 | 7 | | 51 (4)| 00:00:01 |
| 11 | VIEW | | 1 | 7 | | 51 (4)| 00:00:01 |
| 12 | SORT UNIQUE | | 1 | 127 | | 51 (4)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 127 | | 50 (2)| 00:00:01 |
|* 14 | HASH JOIN | | 1 | 68 | | 44 (3)| 00:00:01 |
|* 15 | TABLE ACCESS BY INDEX ROWID| SUBJECT_COMPONENT | 13 | 520 | | 40 (0)| 00:00:01 |
|* 16 | INDEX RANGE SCAN | SUBJECT_COMPONENT_ASSESS_TYPE | 1059 | | | 9 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | SUBJECT_GROUP_PK | 41 | 1148 | | 3 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | CEA_AUTOMATIC_ALLOCATION_STATS | 5 | 295 | | 6 (0)| 00:00:01 |
| 19 | VIEW | | 679 | 48888 | | 2133 (6)| 00:00:33 |
| 20 | SORT GROUP BY | | 679 | 25123 | | 2133 (6)| 00:00:33 |
|* 21 | HASH JOIN | | 52408 | 1893K| 1744K| 2126 (6)| 00:00:33 |
| 22 | TABLE ACCESS BY INDEX ROWID | IA_INSTANCES | 52408 | 1125K| | 688 (1)| 00:00:11 |
|* 23 | INDEX RANGE SCAN | IND_IA_INSTANCES | 49077 | | | 137 (2)| 00:00:03 |
| 24 | TABLE ACCESS FULL | WORKFLOW_INSTANCE | 1075K| 15M| | 960 (7)| 00:00:15 |
|* 25 | TABLE ACCESS BY INDEX ROWID | PERSON | 1 | 27 | | 1 (0)| 00:00:01 |
|* 26 | INDEX UNIQUE SCAN | PERSON_PK | 1 | | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(TO_NUMBER(:V_START_ROW)<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1))
2 - filter("ROW_NUM">=TO_NUMBER(:V_START_ROW) AND "ROW_NUM"<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1))
8 - access("EXNAME"."EXAMINER_CODE"="IAF"."EXAMINER_CODE"(+))
14 - access("SC"."SUBJECT"="SG"."SUBJECT" AND "SC"."LVL"="SG"."LVL")
15 - filter((:V_SUBJECT IS NULL OR "SC"."SUBJECT"=:V_SUBJECT) AND ("SC"."LVL"=:V_LVL OR :V_LVL IS NULL))
16 - access("SC"."YEAR"=TO_NUMBER(:V_YEAR) AND "SC"."MONTH"=:V_MONTH)
17 - access("SG"."YEAR"=TO_NUMBER(:V_YEAR) AND "SG"."MONTH"=:V_MONTH)
filter(:V_SUBJECT_GROUP IS NULL OR "SG"."GROUP_NUMBER"=TO_NUMBER(:V_SUBJECT_GROUP))
18 - access("CEA"."YEAR"=TO_NUMBER(:V_YEAR) AND "CEA"."MONTH"=:V_MONTH AND "SC"."PAPER_CODE"="PAPER_CODE" AND
"CEA"."ELEMENT"='Moderation of IA')
filter("CEA"."ELEMENT"='Moderation of IA' AND (:V_PADDED_EXAMINER_CODE IS NULL OR
"EXAMINER_CODE"=:V_PADDED_EXAMINER_CODE))
21 - access("WFI"."INSTANCE_ID"="IA1"."WORKFLOW_INSTANCE_ID")
23 - access("IA1"."YEAR"=TO_NUMBER(:V_YEAR) AND "IA1"."MONTH"=:V_MONTH)
25 - filter(:V_EXAMINER_NAME IS NULL OR UPPER("TITLE"||' '||"FIRSTNAME"||' '||"LASTNAME") LIKE :V_SEARCH_EXAMINER_NAME)
26 - access("EXNAME"."EXAMINER_CODE"="PERSON_CODE")
53 rows selectedHi,
please find the below rigjt explan paln.
PLAN_TABLE_OUTPUT
SQL_ID 2ct41vyyzqyh7, child number 0
SELECT * FROM (SELECT q.*, COUNT(*) OVER() AS record_count, ROWNUM AS row_num FROM (SELECT
ExName.examiner_code, examiner_name, :v_year, :v_month, count_fb, NVL(count_entered_fb,
0) count_entered_fb, NVL(count_sent_fb, 0) count_sent_fb, NVL(count_edited_fb, 0) count_edited_fb,
NVL(count_complete_fb, 0) count_complete_fb, NVL(count_withibcardiff_fb, 0) count_withibcardiff_fb FROM
(SELECT examiner_code, COUNT(*) AS count_fb FROM (SELECT
examiner_code, paper_code, assessment_school FROM ( SELECT DISTINCT
ce.examiner_code, ce.paper_code, ce.assessment_school FROM (SELECT
DISTINCT assessment_school,
paper_code, examiner
Plan hash value: 651311258
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | | 2785 (100)| |
|* 1 | FILTER | | | | | | |
|* 2 | VIEW | | 4 | 1104 | | 2785 (7)| 00:00:43 |
| 3 | WINDOW BUFFER | | 4 | 1000 | | 2785 (7)| 00:00:43 |
| 4 | COUNT | | | | | | |
| 5 | VIEW | | 4 | 1000 | | 2785 (7)| 00:00:43 |
| 6 | NESTED LOOPS | | 4 | 476 | | 2785 (7)| 00:00:43 |
| 7 | MERGE JOIN OUTER | | 4 | 368 | | 2781 (7)| 00:00:43 |
| 8 | VIEW | | 4 | 80 | | 72 (3)| 00:00:02 |
| 9 | SORT GROUP BY | | 4 | 28 | | 72 (3)| 00:00:02 |
| 10 | VIEW | | 4 | 28 | | 72 (3)| 00:00:02 |
| 11 | SORT UNIQUE | | 4 | 508 | | 72 (3)| 00:00:02 |
| 12 | NESTED LOOPS | | 4 | 508 | | 71 (2)| 00:00:02 |
|* 13 | HASH JOIN | | 1 | 68 | | 44 (3)| 00:00:01 |
|* 14 | TABLE ACCESS BY INDEX ROWID| SUBJECT_COMPONENT | 13 | 520 | | 40 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | SUBJECT_COMPONENT_ASSESS_TYPE | 1059 | | | 9 (0)| 00:00:01 |
|* 16 | INDEX RANGE SCAN | SUBJECT_GROUP_PK | 41 | 1148 | | 3 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | CEA_AUTOMATIC_ALLOCATION_STATS | 30 | 1770 | | 27 (0)| 00:00:01 |
|* 18 | SORT JOIN | | 576 | 41472 | | 2709 (7)| 00:00:42 |
| 19 | VIEW | | 576 | 41472 | | 2708 (7)| 00:00:42 |
| 20 | SORT GROUP BY | | 576 | 21312 | | 2708 (7)| 00:00:42 |
|* 21 | HASH JOIN | | 52408 | 1893K| 1744K| 2701 (7)| 00:00:41 |
|* 22 | TABLE ACCESS FULL | IA_INSTANCES | 52408 | 1125K| | 1263 (6)| 00:00:20 |
| 23 | TABLE ACCESS FULL | WORKFLOW_INSTANCE | 1075K| 15M| | 960 (7)| 00:00:15 |
|* 24 | TABLE ACCESS BY INDEX ROWID | PERSON | 1 | 27 | | 1 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | PERSON_PK | 1 | | | 0 (0)| |
Predicate Information (identified by operation id):
1 - filter(TO_NUMBER(:V_START_ROW)<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1))
2 - filter(("ROW_NUM">=TO_NUMBER(:V_START_ROW) AND "ROW_NUM"<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1)))
13 - access("SC"."SUBJECT"="SG"."SUBJECT" AND "SC"."LVL"="SG"."LVL")
14 - filter(((:V_SUBJECT IS NULL OR "SC"."SUBJECT"=:V_SUBJECT) AND ("SC"."LVL"=:V_LVL OR :V_LVL IS NULL)))
15 - access("SC"."YEAR"=TO_NUMBER(:V_YEAR) AND "SC"."MONTH"=:V_MONTH)
16 - access("SG"."YEAR"=TO_NUMBER(:V_YEAR) AND "SG"."MONTH"=:V_MONTH)
filter((:V_SUBJECT_GROUP IS NULL OR "SG"."GROUP_NUMBER"=TO_NUMBER(:V_SUBJECT_GROUP)))
17 - access("CEA"."YEAR"=TO_NUMBER(:V_YEAR) AND "CEA"."MONTH"=:V_MONTH AND "SC"."PAPER_CODE"="PAPER_CODE" AND
"CEA"."ELEMENT"='Moderation of IA')
filter(("CEA"."ELEMENT"='Moderation of IA' AND (:V_PADDED_EXAMINER_CODE IS NULL OR
"EXAMINER_CODE"=:V_PADDED_EXAMINER_CODE)))
18 - access("EXNAME"."EXAMINER_CODE"="IAF"."EXAMINER_CODE")
filter("EXNAME"."EXAMINER_CODE"="IAF"."EXAMINER_CODE")
21 - access("WFI"."INSTANCE_ID"="IA1"."WORKFLOW_INSTANCE_ID")
22 - filter(("IA1"."MONTH"=:V_MONTH AND "IA1"."YEAR"=TO_NUMBER(:V_YEAR)))
24 - filter((:V_EXAMINER_NAME IS NULL OR UPPER("TITLE"||' '||"FIRSTNAME"||' '||"LASTNAME") LIKE :V_SEARCH_EXAMINER_NAME))
25 - access("EXNAME"."EXAMINER_CODE"="PERSON_CODE")
66 rows selected -
Need a help to write the query
Hi,
I need a small help to write the query.
I have a table contains couponid,coupon,createdate,expirationdate,assigndate from couponday table
i want to write the query to select the coupon whose Expiry date in the table is NOT within 30 days.
Thanks in advanceHi,
user586 wrote:
i want to write the query to select the coupon whose Expiry date in the table is NOT within 30 days.If you mean expirationdate (datatype: DATE) is not within 30 days (past or future) of run time, then:
SELECT coupon -- or whatever columns you want
FROM table_x
WHERE expirationdate NOT BETWEEN SYSDATE - 30
AND SYSDATE + 30
; -
Pls help me to modify the query for performance improvement
Hi,
I have the below initialization
DECLARE @Active bit =1 ;
Declare @id int
SELECT @Active=CASE WHEN id=@id and [Rank] ='Good' then 0 else 1 END FROM dbo.Students
I have to change this query in such a way that the conditions id=@id and [Rank] ='Good' should go to the where condition of the query. In that case, how can i use Case statement to retrieve 1 or 0? Can you please help me to modify this initialization?I dont understand your query...May be below? or provide us sample data and your output...
SELECT * FROM dbo.students
where @Active=CASE
WHEN id=@id and rank ='Good' then 0 else 1 END
But, I doubt you will have performance improvement here?
Do you have index on id?
If you are looking for getting the data for @ID with rank ='Good' then use the below:Make sure, you have index on id,rank combination.
SELECT * FROM dbo.students
where id=@id
and rank ='Good' -
In query designer , cant able to change/modify the query porperties
hai experts / friends
even in production or develeopment i have selected one query in query designer and opened and after that am selecting one default value and then right hand side it displays the properties of that particular query then i can not modify the changes ...that Display and change option is in disable....how can i enable this button...
please help me friends...
previously i have tried using production and then i thought because of production it is not getting enabled then i tried in development , and came to know that even in development also same problem it is not getting enabled....
thanks in advance..
regards
anandhai friends..
thanks for all your reply...
actually i want to explain detail ..
after selecting the one particular query , am just placing the mouse in my charecteristics restrictions and then right hand side
properties window gets displayed and at the top we can find display/change button and save button technical name
button
in that display and change button is disabled...i want that button to be enabled.
i have checked in my authorizations in SU01...
even i have all the profiles like SAP_ALL ...
and then i have been trying to have transaport connection and then creating transport conn. for BeX...but it is asking package name...
in this case i dont know the exact package name....
can any body help me in this regard???
thanks
anand -
Hi All,
I am a new DBA. Please help me in modifying the below query in test envirnoment. It is long query.
SELECT NVL(MIN(P_LAY),0), NVL(MIN(TID),0), NVL(MIN(TTIME),0), NVL(MIN(TSOURCE),0) FROM ( SELECT P_LAY, TID, TTIME, TSOURCE FROM ( SELECT (CASE WHEN T1.INTERNAL_TYPE=3 THEN -1 ELSE T_REPORT.GET_LAY(T1.EVE_ID, T1.EVE_TIME,:B4 ) END ) P_LAY, T1.EVE_ID TID, T1.EVE_TIME TTIME, T1.ALA_SOURCE_ID TSOURCE FROM T_EVE_LOG T1, T_EVE_LOG T2 WHERE T1.ALA_ID = T2.ROOT_ALA_ID AND T2.EVE_TIME >= :B3 AND T2.EVE_TIME < :B2 AND T2.ALA_ID = :B1 AND T2.ACT_ID IN (2,5) ) ORDER BY P_LAY ) WHERE ROWNUM = 1
Thanks in Advance886755 wrote:
Hi All,
I am a new DBA. Please help me in modifying the below query in test envirnoment. It is long query.
SELECT NVL(MIN(P_LAY),0), NVL(MIN(TID),0), NVL(MIN(TTIME),0), NVL(MIN(TSOURCE),0) FROM ( SELECT P_LAY, TID, TTIME, TSOURCE FROM ( SELECT (CASE WHEN T1.INTERNAL_TYPE=3 THEN -1 ELSE T_REPORT.GET_LAY(T1.EVE_ID, T1.EVE_TIME,:B4 ) END ) P_LAY, T1.EVE_ID TID, T1.EVE_TIME TTIME, T1.ALA_SOURCE_ID TSOURCE FROM T_EVE_LOG T1, T_EVE_LOG T2 WHERE T1.ALA_ID = T2.ROOT_ALA_ID AND T2.EVE_TIME >= :B3 AND T2.EVE_TIME < :B2 AND T2.ALA_ID = :B1 AND T2.ACT_ID IN (2,5) ) ORDER BY P_LAY ) WHERE ROWNUM = 1
Thanks in Advancemodify it how to do what?
SELECT Nvl(MIN(p_lay), 0),
Nvl(MIN(tid), 0),
Nvl(MIN(ttime), 0),
Nvl(MIN(tsource), 0)
FROM (SELECT p_lay,
tid,
ttime,
tsource
FROM (SELECT ( CASE
WHEN t1.internal_type = 3 THEN -1
ELSE t_report.Get_lay(t1.eve_id, t1.eve_time, :B4)
END ) p_lay,
t1.eve_id tid,
t1.eve_time ttime,
t1.ala_source_id tsource
FROM t_eve_log t1,
t_eve_log t2
WHERE t1.ala_id = t2.root_ala_id
AND t2.eve_time >= :B3
AND t2.eve_time < :B2
AND t2.ala_id = :B1
AND t2.act_id IN ( 2, 5 ))
ORDER BY p_lay)
WHERE ROWNUM = 1 -
Hello
I have created 2 user defined fields
Field 1 must be changed by the user before they save the sales order, it's a numeric field, value is 0 or 1. Field is called 'SPRECPTE'
The second field is a field to block the user as long as the above field is not changed. This field is alphanumeric and mandatory but the problem is when you create the UDF you must define a default value.
Here comes the query to remove the default value and make the control possible when you select the cardcode from OCRD.
Then the field 2 is blank and it must be field up to allow booking when you change UDF1 from 0 to 1. But the query work to empty the field 2 but it does not when SPRECPTE is equal to 1
Declare @U_SPRECPTE as numeric (1,0)
Set @U_SPRECPTE = $[$U_SPRECPTE.1.0]
IF U_SPRECPTE=0
Select '' ELSE 'A'During order entry, the system checks freight cost based on formated search to add sales tax on freight fields.It was calculated for every line.
Now we are in live condition the formated search slows down order entry as every time an item is keyed in it recalculates every item again....
Then I decide to stop the fms based on item feild is modified and to valide the calculation before saving the order
To secure a sales order is saved without calculating the whole order I created 2 UDF to block users....
So one UDF must be mandatory and without default value, the first field launch the calculation through FMS of the whole order
I hope I am clear I am not familair with SBO store procedure but if you think it may help please explain
B Regards -
Is ther any otherway i can modify the below query to create emp_target to get the expected result below at the end
CREATE EMP_TARGET as
SELECT emp.empno,emp.ename, emp.deptNO,dept.dname,EMP.mod_time,dept.mod_time FROM
(SELECT * FROM EMP WHERE MOD_TIME <=to_date('31-JUL-2012','DD-MON-YYYY'))emp
left join
(select * from dept WHERE MOD_TIME <=to_date('31-JUL-2012','DD-MON-YYYY') ) dept
on
emp.DEPTNO=dept.DEPTNO
CREATE TABLE EMP
EMPNO INT NOT NULL ,
ENAME VARCHAR(10) ,
JOB VARCHAR(9) ,
MGR INT ,
SAL NUMERIC(7,2) ,
DEPTNO INT,
mod_time date
CREATE TABLE DEPT
DEPTNO INT,
DNAME VARCHAR(14),
LOC VARCHAR(13) ,
mod_time date
INSERT INTO emp VALUES
(7369, 'SMITH', 'CLERK', 7902, 800, 20,to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7499, 'ALLEN', 'SALESMAN', 7698, 1600, 30,to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7521, 'WARD', 'SALESMAN', 7698, 1250, 30,to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7566, 'JONES', 'MANAGER', 7839, 2975, 20,to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7654, 'MARTIN', 'SALESMAN', 7698, 1250, 30,to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7698, 'BLAKE', 'MANAGER', 7839, 2850, 30,to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7782, 'CLARK', 'MANAGER', 7839, 2450, 10,to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7788, 'SCOTT', 'ANALYST', 7566, 3000, 20,to_DATE('01-SEP-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7839, 'KING', 'PRESIDENT', NULL, 5000, 10,to_DATE('01-SEP-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7844, 'TURNER', 'SALESMAN', 7698, 1500, 30,to_DATE('01-SEP-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7876, 'ADAMS', 'CLERK', 7788, 1100, 20,to_DATE('01-SEP-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7900, 'JAMES', 'CLERK', 7698, 950, 30,to_DATE('01-SEP-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7902, 'FORD', 'ANALYST', 7566, 3000, 60,to_DATE('01-SEP-2012','DD-MON-YYYY'));
INSERT INTO EMP VALUES
(7934, 'MILLER', 'CLERK', 7782, 1300, 10,to_DATE('01-SEP-2012','DD-MON-YYYY'));
SELECT * FROM EMP
INSERT INTO DEPT
VALUES (10, 'ACCOUNTING', 'NEW YORK',to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO DEPT
VALUES (20, 'RESEARCH', 'DALLAS',to_DATE('31-JUL-2012','DD-MON-YYYY'));
INSERT INTO DEPT
VALUES (30, 'SALES', 'CHICAGO',to_DATE('01-SEP-2012','DD-MON-YYYY'));
INSERT INTO DEPT
VALUES (40, 'OPERATIONS', 'BOSTON',to_DATE('01-SEP-2012','DD-MON-YYYY'));
SELECT * FROM DEPT
CREATE EMP_TARGET as
SELECT emp.empno,emp.ename, emp.deptNO,dept.dname,EMP.mod_time,dept.mod_time FROM
(SELECT * FROM EMP WHERE MOD_TIME <=to_date('31-JUL-2012','DD-MON-YYYY'))emp
left join
(select * from dept WHERE MOD_TIME <=to_date('31-JUL-2012','DD-MON-YYYY') ) dept
on
emp.DEPTNO=dept.DEPTNO
Emp_target expected result
empno ename deptno dname emp_mod_time dept_mod_time
7782 CLARK 10 ACCOUNTING 31-JUL-12 31-JUL-12
7566 JONES 20 RESEARCH 31-JUL-12 31-JUL-12
7369 SMITH 20 RESEARCH 31-JUL-12 31-JUL-12
7698 BLAKE 30 31-JUL-12
7654 MARTIN 30 31-JUL-12
7521 WARD 30 31-JUL-12
7499 ALLEN 30 31-JUL-12 Edited by: choti on Jan 8, 2013 10:20 AMHi,
choti wrote:
CREATE TABLE EMP
EMPNO INT NOT NULL ,
ENAME VARCHAR(10) ,
JOB VARCHAR(9) ,
MGR INT ,
SAL NUMERIC(7,2) ,
DEPTNO INT,
mod_time date
Thanks for posting the CREATE TABLE and INSERT statements.
Remember why you need to go to all that trouble: so the people who want to help you can re-create the problem and test their ideas. If you post statements that don't work, then people can't use them. Please test (and, if necessary, correct) your statements before you post them.
There is no NUMERIC datatype in Oracle SQL. I think you meant the datatype of sal to be NUMBER.
Here's one way to create the emp_target table:
CREATE TABLE emp_target
AS
SELECT e.empno
, e.ename
, e.deptno
, d.dname
, e.mod_time AS emp_mod_time
, d.mod_time AS dept_mod_time
FROM emp e
LEFT OUTER JOIN dept d ON d.deptno = e.deptno
AND d.mod_time <= TO_DATE ('31-JUL-2012','DD-MON-YYYY')
WHERE e.mod_time <= TO_DATE ('31-JUL-2012','DD-MON-YYYY')
; -
How to modify the query to get max id record
Hi All,
How to modify below query to get proper result.The query is returning some records are duplicated.I need only one record to display from duplicate based on max assetid.
Here is my query:
SELECT *
FROM (
SELECT a.uppertitle, a.composer, a.esongid,
MAX (asset_new.assetid) AS assetid,asset_new.ownerid
FROM (SELECT DISTINCT NVL (esong.title, '~') AS uppertitle,
INITCAP (NVL (esong.composer, '~')
) AS composer,
esong.esongid
FROM esong, esongcountry_us eus
WHERE 1 = 1
AND eus.esongid = esong.esongid
AND eus.isocountrycode IN ('US')
AND esong.title LIKE 'LIVE TO TELL%'
AND ROWNUM < 390) a,
songwebrecording,
recordingasset_new,
asset_new
WHERE a.esongid = songwebrecording.esongid(+)
AND songwebrecording.recordingid = recordingasset_new.recordingid(+)
AND recordingasset_new.assetid = asset_new.assetid(+)
GROUP BY a.uppertitle, a.composer, a.esongid,asset_new.ownerid)
WHERE ROWNUM <= 390
ORDER BY uppertitle
result:
upperlittle composer esongid assetid onwerid
1. LIVE TO TELL Gelb, Howe 480340000 null null
2. LIVE TO TELL FROM THE Madonna (Ca)/ Leonard 125559900 null null
3. LIVE TO TELL FROM THE Madonna (Ca)/ Leonard 125559900 3080366 null
4. LIVE TO TELL FROM THE Madonna (Ca)/ Leonard 125559900 3038107 null
5. LIVE TO TELL THE TALE Holopainen 859841500 nulll nulll
I need the result like this :
upperlittle composer esongid assetid onwerid
1. LIVE TO TELL Gelb, Howe 480340000 null null
2. LIVE TO TELL FROM THE Madonna (Ca)/ Leonard 125559900 3080366 null
3. LIVE TO TELL THE TALE Holopainen 859841500 nulll nulll
Please help me on this regard. oracle version is 9i
Regards,
Rajasekharcan you please format your code with
-
Can i modify the query in discoverer
Hi
I am working on discoverer vierwer, is it possible to change the query and run the query myself. I can access the query but i can't make any changes.
The problem i am having is i want to show the sum of a variable but not show the count, is this possible ?
any help would be appreciated
thanks
nimeshHi Nimesh
Presumably the workbook you are referring to is not owned by you and has only been shared with you? In this case, while you can make changes to the query while it is in memory, providing you have the necessary privileges that is, you will not be able to save over the original. This is because only the owner can do this and you are not the owner.
What you can do though is to use Save As and save ourself a variant of the report. Of course this opens up another spoke in the wheel of reinvented queries, something that most organizations would like to avoid.
Therefore, perhaps the best option would be to contact the owner of the workbook and request that it be modified for your needs.
I hope this helps
Best wishes
Michael Armstrong-Smith
URL: http://learndiscoverer.com
Blog: http://learndiscoverer.blogspot.com -
How to modify the query to get the output in a single row
Hi All,
Below is the query i have written it works fine
select DISTINCT right(left(CTACCT,13),4) AS LocationNum,
tODS_GLBalance.FiscalYearId AS FiscalYearId,
tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
--tods_GLMetadata.Metric,
Case when
tods_GLMetadata.Metric = 'Gross Margin'
Then SUM(Balance)
Else 0
END AS GrossMargin,
Case when
tods_GLMetadata.Metric = 'Occupancy'
Then SUM(Balance)
Else 0
END AS Occupancy,
Case when
tods_GLMetadata.Metric = 'Payroll Dollars'
Then SUM(Balance)
Else 0
END AS Payroll,
Case when
tods_GLMetadata.Metric = 'CF Sales'
Then SUM(Balance)
Else 0
END AS OperatingSales,
Case when
tods_GLMetadata.Metric = 'Operations'
Then SUM(Balance)
Else 0
END AS OperatingExpenses
-- 0 as payroll
from ods.[JJill].[tODS_GLBalance]
inner join ods.Staging.tODS_INF_GLPCT ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
inner join ods.JJill.tods_GLMetadata ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
where
(tODS_GLBalance.FiscalYearId = 2012) and
(tODS_GLBalance.FiscalMonthOfYearId = 2) and
(right(left(CTACCT,13),4)= 3020)
group by
right(left(CTACCT,13),4),
tODS_GLBalance.FiscalYearId,
tODS_GLBalance.FiscalMonthOfYearId,
tods_GLMetadata.Metric
This is the sample output,
LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
3020 2012 2 -112477.00 0.00 0.00 0.00 0.00
3020 2012 2 0.00 0.00 0.00 -158288.94 0.00
3020 2012 2 0.00 0.00 0.00 0.00 5625.44
3020 2012 2 0.00 0.00 24185.79 0.00 0.00
3020 2012 2 0.00 31075.53 0.00 0.00 0.00
But, i am expecting the output to be something like this
LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
3020 2012 2 -112477.00 31075.53 24185.79 -158288.94 5625.44
Can someone please help me with changing my query to get the desired output?
Please let me know if you have any questions.
ThanksTry this:
SELECT DISTINCT
RIGHT(LEFT(CTACCT,13),4) AS LocationNum, tODS_GLBalance.FiscalYearId AS FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
SUM(CASE WHEN tods_GLMetadata.Metric = 'Gross Margin' THEN Balance ELSE 0 END ) AS GrossMargin,
SUM(CASE WHEN tods_GLMetadata.Metric = 'Occupancy' THEN Balance ELSE 0 END ) AS Occupancy,
SUM(CASE WHEN tods_GLMetadata.Metric = 'Payroll Dollars' THEN Balance ELSE 0 END ) AS Payroll,
SUM(CASE WHEN tods_GLMetadata.Metric = 'CF Sales' THEN Balance ELSE 0 END ) AS OperatingSales,
SUM(CASE WHEN tods_GLMetadata.Metric = 'Operations' THEN Balance ELSE 0 END ) AS OperatingExpenses
FROM ods.[JJill].[tODS_GLBalance]
INNER JOIN ods.Staging.tODS_INF_GLPCT
ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
INNER JOIN ods.JJill.tods_GLMetadata
ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
WHERE tODS_GLBalance.FiscalYearId = 2012
AND tODS_GLBalance.FiscalMonthOfYearId = 2
AND RIGHT(LEFT(CTACCT,13),4) = 3020
GROUP BY right(left(CTACCT,13),4), tODS_GLBalance.FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId, tods_GLMetadata.Metric -
Need help in modifying the column length
Hi Experts,
I need to modify the length of a column from char(10) to char(5), but it's showing the error of:
ALTER TABLE appr_group_table MODIFY (APPR_TBLNO CHAR(5)) It's showing the below error:
ERROR at line 1:
ORA-01441: cannot decrease column length because some value is too bigI've checked in the dbase but there is no any value of this column having more than 5 characters:
SQL> SELECT APPR_TBLNO FROM appr_group_table;
APPR_TBLNO
ANTAB
ANTAB
ANTST
SCCTR
SOTAB
SOTAB
SOTAB
SOTAB
SOTAB
SOTAB
SOTAB
11 rows selected.Thnx in advance for helping me out.....char means fixed length variable. when you say char(10) oracle will reserve 10 places for your data. that means in your output what you are seeing as blank spaces are also considered as data. that is the reason, it is not allowing you to reduce the size.
better solution is to create new column with varchar2 or char(5) datatype and transfer this column data into new column and then drop original column. -
Need help in writing the query
The initial data is as follows:
ID PARENT_ID
=============
1 NULL
2 NULL
3 2
4 6
5 3
6 7
7 4
8 NULL
but output is as follows in such way that Parent_Id should be displayed in ID place
ID PARENT_ID
=============
1 NULL
2 NULL
3 2
8 NULL
6 8
4 6
5 3
7 4
Can any one help how resolve this query?
Thanks in advanceYour output is inconsistent with initial data :) But
select * from t start with parent_id is null connect by parent_id = prior id;
Maybe you are looking for
-
I play Zynga's Cafeworld on Facebook. The "recent" key on the newsfeed has disappeared with the upgrade to Firefox 6. I must go to individual walls to get current requests. How can I fix this?
-
Can't use jmfinit and usb webcam or tvcard
I am trying to use jmfinit.exe and it seems to stop after: DirectSound Capture Supported = true DirectSoundAuto: Committed ok JavaSound Capture Supported = true JavaSoundAuto: Committed ok Found device Microsoft WDM Image Capture (Win32) Querying dev
-
BAPI/FM to modify the FI posting period
Hi All, Is there any BAPI/FM to Modify the FI posting period. I know we can use BDC on TCode OB52 for modifying the FI posting period. But i want to keep this as a last option. Thanks, Sridhar
-
Process For Electricity Bill Payment in SAP
We need to deploy an automated process for electricity bill payments for a customer. What is the best practice that could be followed to automate electricity bill payments where the electricity service provider just auto-debits the customer based on
-
Exception Handling in Biztalk Orchestration
Hi all, I have handled the exception from the send and receive port using the Errorreport promoted property in my EDI application. But I need to handle exceptions that are raised from the orchestration also. Kindly advice how to handle the same with