Modifying Query

Hello,
We currently use this Query below as a Commission Report for our sales team:
SELECT 'Invoice' "Invoice/AR Credit Memo", T0.CardCode "BP Code", T0.CardName "Company", T0.DocDate,T0.DocNum, T0.DocTotal "Gross Amt", T0.TotalExpns "Freight/Svc Charge", (T0.DocTotal - T0.VatSum-T0.TotalExpns) "Net Order", T1.SlpName "Sales Rep", T1.Commission "% Commision",
((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(T1.Commission/100)) "Commission Amount"
FROM [dbo].[OINV] T0 INNER JOIN [dbo].[OSLP] T1 ON T0.SlpCode = T1.SlpCode
WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND (T0.DocDate BETWEEN '[%2]' AND '[%3]')
UNION ALL
SELECT 'Credit Memo', T0.CardCode, T0.CardName, T0.DocDate, T0.DocNum, -T0.DocTotal, -T0.TotalExpns, -(T0.DocTotal - T0.VatSum-T0.TotalExpns), T1.SlpName, T1.Commission,
((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(-T1.Commission/100))
FROM [dbo].[ORIN] T0 INNER JOIN [dbo].[OSLP] T1 ON T0.SlpCode = T1.SlpCode
WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND (T0.DocDate BETWEEN '[%2]' AND '[%3]')
We would like to add a column for Address, City, State, Zip, Phone and Contact after the Company name. 
Can anyone provided assistance with this?
Thanks!
Mike

Mike,
Here you are:
SELECT 'Invoice' "Invoice/AR Credit Memo", T0.CardCode "BP Code", T0.CardName "Company",
T0.Address, T2.Phone1, T3.Name, T0.DocDate,T0.DocNum, T0.DocTotal "Gross Amt", T0.TotalExpns
"Freight/Svc Charge", (T0.DocTotal - T0.VatSum-T0.TotalExpns) "Net Order", T1.SlpName "Sales Rep",
T1.Commission "% Commision",
((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(T1.Commission/100)) "Commission Amount"
FROM dbo.OINV T0 INNER JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
INNER JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
INNER JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND (T0.DocDate BETWEEN '[%2]' AND '[%3]')
UNION ALL
SELECT 'Credit Memo', T0.CardCode, T0.CardName, T0.Address, T2.Phone1, T3.Name,T0.DocDate,
T0.DocNum, -T0.DocTotal, -T0.TotalExpns, -(T0.DocTotal - T0.VatSum-T0.TotalExpns), T1.SlpName, T1.Commission,
((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(-T1.Commission/100))
FROM dbo.ORIN T0 INNER JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
INNER JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
INNER JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
{WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND (T0.DocDate BETWEEN '[%2]' AND '[%3]')
Thanks,
Gordon

Similar Messages

  • Cfldap modify query to add members to group

    Hi,
    I am trying to add new members to the group using cfldap modify query.
    i am able replace with one member with the other but the requirement is like that we supposed to add new member with the existing one.
    query that i have used is
    <cfldap
         ACTION="modify"
                          Modifytype="REPLACE"
                          DN="#groupdn#"
                          ATTRIBUTES="MEMBER=#existingmembers#, cn=XXX, ou=xxx,o=xxxx"
                          separator="|"
                          secure="#secure#"
                          server="#ldapServer#"
                          username="#ldapuser#"
                          password="#ldapPassword#"
                          port="#ldapPort#"
                         >
    It is giving syntax violation error.
    please help me get it resolved.
    Thanks in advance.

    Just to add to the query above, if you want to see request group along with request_group_id you do join as follows
    SELECT frv.responsibility_name
    ,frg.request_group_name
    FROM fnd_request_groups frg,
    fnd_request_group_units frgu,
    fnd_responsibility_vl frv
    WHERE 1 = 1
    AND frgu.request_group_id = frg.request_group_id
    AND frv.request_group_id = frg.request_group_id
    ORDER BY responsibility_name
    Thanks
    Shailendra

  • Modify Query in Production System !

    Hello SDN s,
    How ya all ?
    We want to Modify a Query by inserting one more <b>InfoObject in the Production System</b>. When we try to <i>Drag & Drop</i> the InfoObject from the Dimension to the <i><b>Free Characteristics</b></i> it showed <b>blocked symbol</b> and hence we are unable to modify the Query.
    We do have to Query in the Development but cannot use that for Transport as it holds another Query Structure which is used by another Production System.
    Could anyone suggest us how to modify the Query ?
    Will there be any authorization to maintain for the user ?
    Best Regards....
    Sankar Kumar
    +91 98403 47141

    Hello Murali,
    Could u list down what are all the Authorizations we have to maintain and where it has to be maintained, in SU01 or some other Transaction ?
    Hello Srini,
    I got this doubt earlier and checked the entire content, the object is not there.
    Hello Edwin Harpino(A.H.P),
    I will try this and come back with the result !

  • Modify query used in Materialized View

    Are there any ways to modify the query used in materialized view without dropping the materialized view. I dont think alter materialized view has such an option.
    Please provider me your suggestions.

    you have to give "ENABLE QUERY REWRITE" option then u can change your query

  • Problem saving a modified query

    Hi Folks,
    I am trying to modify an existing query. when I save the changes it throws a error message saying
    "Object ELEM 46I8....................... could not be saved to order BWDK906565"
    The above request was all ready created by another user.
    Let me know how to resolve this issue.
    Arjun

    Hi,
    Maybe there is some issue with that transport. Import that change and then try to save ur change in new transport.
    Hope it  helps.
    Regards,
    Rathy

  • Not able to modify Query

    Hi,
    I created a query in Development and tranported to Test and now I am trying to modify this query in Dev using Query Designer, it doesn't..
    'Error: The query could not be saved due to problem in transport'
    all my requests are released in Dev and transported to Test. I tried to delete this query using RSZDELTE but
    "Query object is blocked. Deletion has been cancelled"

    Thanks for the suggestion, I could modify it once I created a new request for this query using tranpost connection and I could able to delete also...
    But I expected the query designer should prompt with a new request if the request doesn't exist (or) error message should be more clearer ... we had this feature before with Bex Analyzer !!!

  • Error of modified query in VO

    Hi,
    I extended a VO by modifying its query to the following:
    SELECT * FROM (select ptv.project_number,
    ptv.project_id,
    ppp.organization_id,
    ptv.task_number,
    ptv.task_name,
    ptv.task_id
    from pjm_project_parameters ppp,
    pjm_tasks_v ptv,
    csi_item_instances cii,
    eam_org_maint_defaults eomd
    where ppp.project_id = ptv.project_id(+)
    and substr(ptv.task_number, 12, 7) = eomd.accounting_class_code
    and eomd.object_id = cii.instance_id
    and eomd.organization_id = ppp.organization_id
    and cii.instance_number = :asset_number
    The execution is fine on the first run but once a value is chosen and the user wants to modify it by clicking again on the small magnifier icon on the jsp page we get this error when we click on go we get the following error:
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (select ptv.project_number,
    ptv.project_id,
    ppp.organization_id,
    ptv.task_number,
    ptv.task_name,
    ptv.task_id
    from pjm_project_parameters ppp,
    pjm_tasks_v ptv,
    csi_item_instances cii,
    eam_org_maint_defaults eomd
    where ppp.project_id = ptv.project_id(+)
    and substr(ptv.task_number, 12, 7) = eomd.accounting_class_code
    and eomd.object_id = cii.instance_id
    and eomd.organization_id = ppp.organization_id
    and cii.instance_number = :asset_number) QRSLT WHERE (( TASK_ID = :3 AND UPPER(TASK_NUMBER) like :4 AND (TASK_NUMBER like :5 OR TASK_NUMBER like :6 OR TASK_NUMBER like :7 OR TASK_NUMBER like :8))) ORDER BY task_number
         at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:71)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         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.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: 1
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
         at oracle.jdbc.driver.OraclePreparedStatement.setObjectAtName(OraclePreparedStatement.java:8210)
         at oracle.jbo.server.OracleSQLBuilderImpl.bindParamValue(OracleSQLBuilderImpl.java:3916)
         at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3335)
         at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:13759)
    It seems as oracle is trying to set a parameter that does not occur inside the query what can be done in order to solve this issue?
    Cheers,
    Carl

    I just figured something REALLY weird that might be the cause of the problem.
    If i repeatedly reproduce the error page the query changes and the parameters increment...
    here is an example
    first error: and cii.instance_number = :asset_number) QRSLT WHERE (( TASK_ID = :3 AND UPPER(TASK_NUMBER) like :4 AND (TASK_NUMBER like :5 OR TASK_NUMBER like :6 OR TASK_NUMBER like :7 OR TASK_NUMBER like :8))) ORDER BY task_number
    second error: and cii.instance_number = :asset_number) QRSLT WHERE (( TASK_ID = :4 AND UPPER(TASK_NUMBER) like :5 AND (TASK_NUMBER like :6 OR TASK_NUMBER like :7 OR TASK_NUMBER like :8 OR TASK_NUMBER like :9))) ORDER BY task_number
    third error: and cii.instance_number = :asset_number) QRSLT WHERE (( TASK_ID = :5 AND UPPER(TASK_NUMBER) like :6 AND (TASK_NUMBER like :7 OR TASK_NUMBER like :8 OR TASK_NUMBER like :9 OR TASK_NUMBER like :10))) ORDER BY task_number
    As it can observed the number of the parameter increment! why? This explains why in the first few execution it works and then the IDs of the parameters get out of sync and this is why i get an error.
    Does anyone have any idea how i can resolve this issue,
    Cheers,
    Carl

  • Issue - Modify Query in Dev Server

    Hi All,
    Few days ago wit did it an homogenues copy from BW PRD to BW DEV, everything was fine.
    Nowadays, when i try to open a query in BW DEV appears "BEX transport request XXXX is not available or not suitable", so i cant modify it. Then i created a BEX TO and works fine !! but my question is :
    I want to be able to modify the reports without a BEX TO, and once i finished all the modification i will include it in a TO trought RSA1----Transport Connections - create a new TO.
    Before Homegenous copy this was the was that we were working.
    Anny suggest or solution ???
    I will assign point
    REGARS
    Edited by: Moderator on Jun 5, 2008 10:28 AM
    *We all know that points will be assigned to deserving replies. There is no need to advertise this fact. Thanks!

    Hi Marcos,
    On which version you are working on 3.5 or 7.x ??
    I worked on the 7.x version of query designer and in that i never come across such thing.
    In inital stage when we started development, we created query's and saved them but it never prompted for any kind of reqeuest in the query designer.  Once our query's designed and user wanted them to transport to production we went to RSA1 and collected query and there object's there in a partucular bex request and released the request, but afterwards whenever we create's or changes the query's in query designer then if BEX request is not created it prompts for that.
    As far as i know Query designer does not request for TO request.
    Thanks
    Dipika.

  • Modify Query in an Existing RDL file

    How do I modify sql statement in an existing rdl file?
    I have opened up the rdl file in VS 2013 and able to modify the report but do not know how to modify the query; the Datasource property doesn't seem to give me an option.

    Hello,
    Of course you can modify the query, but not in "Datasource", you find the queries in the (may serveral) "Dataset" definition.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to modify query

    I have a situation where I need to include more than a 1000 values inside an IN clause.
    My query is this. How can I modify it to do so?
    SELECT p.pat_seq, p.diagnosis_type, ct.code_value || ' ' || p.alt_description as diagnosis_desc
    FROM patient_diagnosis p,
    (select * from code_set , code_set_type
    where code_set.code_set_type_seq =code_set_type.code_set_type_seq) ct
    WHERE p.enterprise_seq = (select enterprise_seq
    from org_lookup
    where organization_seq = 0 and rownum = 1)
    and p.diagnosis_code_seq = ct.code_set_seq(+)
    and (p.diagnosis_type LIKE 'A%' OR p.diagnosis_type LIKE 'W%')
    and p.PAT_SEQ IN
    (list 1000 pat_seq)
    OR p.PAT_SEQ IN (more pat_seq) ORDER BY p.pat_seq

    If pat_seq can be obtained from a previous query, then you can embed that query in the IN clause.
    There is a limit of 1000 values when you add hardcoded values in the IN clause.
    There is no limit if you use a subquery in the IN clause.
    If you need to use the list of pat_seq more than once in the same query, you could use the WITH clause (introduced in 9i) as an alternative to a temp table.
    Thanks
    Shakti
    (http://www.impact-sol.com)
    (Developers of Guggi Oracle)

  • Modify query

    Hi all
    I have set up a UDF call 'invoice number' on the AR invoice document header to automatically populate the invoice number. Below is the query i have used
    SELECT $[$8.0.0]
    I need to modify this query so that it puts  a letter eg: D infront of the number
    eg invoice number on the AR invoice doc is 5000. On the UDF of the document the invoice number needs to populate as D5000
    With the above query it just put 5000
    can someone please help me with this query
    Thanks
    Regards
    Apsara

    Hi Apsara ,
    $[OINV.DocNum]
      , this syntax is use to pick the On screen Value .
    So , your FMS should be like :
    SELECT 'D'+ $[OINV.DOCNUM]
    Thanks
    Ashish

  • Modify Query values

    Hi experts,
    Is there a way to modify the result values of a query in ABAP befor they are displayed? i am reading gl account from a hierarchy and extracting their values, but i need to do some custom computation to them before they are displayed to the user.

    Hi.
    May be approach with virtual key figures will help you.
    Regards.

  • Modify Query at runtime

    Hi everyone,
    I use Forms 6i to connect to a non-Oracle data source.
    Just wondering, can we modify the select query at runtime?
    I read the online help for the pre-select trigger. In the "Usage Notes", it says "Use a Pre-Select trigger to prepare a query prior to execution against a non-ORACLE data source."
    I can get the constructed query :system.last_query here. But I can't modify it at this stage.
    Please Help. Thanks

    Hi,
    I do use pre-query, but I use it to modify either the where or order by clause of the select statement. If that is what you want then you could use the set_block_property
    Example;
    set_block_property('blockname', default_where,'new condition');
    Hope this helps.
    Regards,
    Bob DJ

  • Crash - CR 2008 crashes constantly when trying to modify query parameters

    Hello,
    When i create a query with 2 parameters of type Date or Date/Time.
    If I try to modify the query sometime after, Crystal Report crashes all the time.
    If i create only 1 parameter of type Date or Date Time, I can modify the query without any problems.
    Any idea why?
    Is there a workaround?
    Thanks

    Install SP2 and test again. If it's still an issue re-post your question.

  • Authorization to modify query

    Hi all,
    i'm creating a role and i need that users with this role can create, modify and execute queries.
    When a user try to modify a query that already exist, Query Designer says that the Bex Order doesn't exist and no authorization to visualize.
    The Bex order is created so i think this is an authorization problem.
    any ideas of how to solve this ?
    thx in advance

    Dear Juan ,
    You have to assign S_RS_COMP1 also for the reporting user and also check if you have given them S_BDS_DS and S_GUI , so that they can save back the changes ...
    Thanks,
    Krish

  • Can some one modify query

    i just want to know how to get url and know what request taking more than 2 seconds
    from a particular table
    thanks for help
    the below query give more than 2 seconds how many request it does not mention what url and which request ...............................i want both of them
    SELECT
    count((SUBSTR(UPPER(LOG_MSG),INSTR(UPPER(LOG_MSG),'REQUEST=',1,1)+8,INSTR(UPPER(LOG_MSG),':',INSTR(UPPER(LOG_MSG),'REQUEST=',1,1),1)-INSTR(UPPER(LOG_MSG),'REQUEST=',1,1)-8))) AS RESP_GT_2_SEC
    FROM OS_ONDEMAND_LOGS WHERE LOG_TIME between to_date('20110721170000','yyyy/mm/dd:hh24:mi:ss') and to_date('20110721175900','yyyy/mm/dd:hh24:mi:ss')
    AND
    ((SUBSTR(UPPER(LOG_MSG),INSTR(UPPER(LOG_MSG),':',1,2)+1,INSTR(UPPER(LOG_MSG),':',1,3)-INSTR(UPPER(LOG_MSG),':',1,2)-1))-(SUBSTR(UPPER(LOG_MSG),INSTR(UPPER(LOG_MSG),':',1,1)+1,INSTR(UPPER(LOG_MSG),':',1,2)-INSTR(UPPER(LOG_MSG),':',1,1)-1))) > 2000
    AND
    ((SUBSTR(UPPER(LOG_MSG),INSTR(UPPER(LOG_MSG),'REQUEST=G',1,1)+8,INSTR(UPPER(LOG_MSG),'&',INSTR(UPPER(LOG_MSG),'REQUEST=G',1,1),1)-INSTR(UPPER(LOG_MSG),'REQUEST=G',1,1)-8)) = upper('GETMAP')
    or
    (SUBSTR(UPPER(LOG_MSG),INSTR(UPPER(LOG_MSG),'REQUEST=G',1,1)+8,INSTR(UPPER(LOG_MSG),'&',INSTR(UPPER(LOG_MSG),'REQUEST=G',1,1),1)-INSTR(UPPER(LOG_MSG),'REQUEST=G',1,1)-8)) = upper('GETFEATURE'))

    duplicated in SQL and PL/SQL forum
    Re: can you modify please
    locking this copy

Maybe you are looking for