What value we need to pass as parameter in where clause in select query

Hi ALL,
I have written following query, it was executing fine and returning me all the rows with search criteria.
SELECT *
FROM
PRTY_RQST PR
JOIN BUSN_APPLC BIAP ON BIAP.BUSN_APPLC_ID = PR.BUSN_APPLC_ID
JOIN INTN_STATS INSTS ON INSTS.INTN_STATS_ID = PR.INTN_STATS_ID
JOIN INTN_PROCES_TYP INTPTY ON INTPTY.INTN_PROCES_TYP_ID = PR.INTN_PROCES_TYP_ID
LEFT JOIN RQST_TYP RQSTYP ON RQSTYP.RQST_TYP_ID = PR.RQST_TYP_ID
JOIN ADDTN_RQST_INFO ADTINF ON PR.PRTY_RQST_ID = ADTINF.PRTY_RQST_ID
JOIN ADDTN_INFO_KEY_TYP ADDKEY ON ADTINF.ADDTN_INFO_KEY_TYP_ID = ADDKEY.ADDTN_INFO_KEY_TYP_ID
JOIN PRTY_KEY PRTKEY ON PR.PRTY_RQST_ID = PRTKEY.PRTY_RQST_ID
JOIN PRTY_KEY_TYP PRKYTP ON PRTKEY.PRTY_KEY_TYP_ID = PRKYTP.PRTY_KEY_TYP_ID
WHERE (BIAP.BUSN_APPLC_NM = 'bpel')
AND (INTPTY.INTN_PROCES_TYP_NM = 'FulfillmentOrder')
AND (PR.UPDT_BY = 'update3')
AND (INSTS.INTN_STATS_NM = 'Submitted')
AND (PR.CHLD_RQST_IND = 'N')
AND (PR.TRACK_RQST_IND = 'Y')
AND (RQSTYP.RQST_TYP_NM = 'PensionPortfolioRebalance')
AND (RQSTYP.RQST_CLASS_NM = 'Composite')
AND (PRKYTP.PRTY_KEY_TYP_NM = 'NPIN')
AND (PRTKEY.PRTY_TYP_VAL = '101101' )
AND (ADDKEY.ADDTN_INFO_KEY_TYP_NM = 'PlanNumber')
AND (ADTINF.ADDTN_RQST_TYP_VALUE = 'TBMBUpdated');
My question here is i don't want pass the value for BIAP.BUSN_APPLC_NM, still want to get the values for remaing conditions. what value i need to pass here.
I tried Null it giving me no rows. can some one help me on this.
Thank you in advance.
Vijay

933325 wrote:
thank you,
since it is search criteria. I have to use OR instead of AND. this resolved my problem.
SELECT *
FROM
PRTY_RQST PR
JOIN BUSN_APPLC BIAP ON BIAP.BUSN_APPLC_ID = PR.BUSN_APPLC_ID
JOIN INTN_STATS INSTS ON INSTS.INTN_STATS_ID = PR.INTN_STATS_ID
JOIN INTN_PROCES_TYP INTPTY ON INTPTY.INTN_PROCES_TYP_ID = PR.INTN_PROCES_TYP_ID
LEFT JOIN RQST_TYP RQSTYP ON RQSTYP.RQST_TYP_ID = PR.RQST_TYP_ID
JOIN ADDTN_RQST_INFO ADTINF ON PR.PRTY_RQST_ID = ADTINF.PRTY_RQST_ID
JOIN ADDTN_INFO_KEY_TYP ADDKEY ON ADTINF.ADDTN_INFO_KEY_TYP_ID = ADDKEY.ADDTN_INFO_KEY_TYP_ID
JOIN PRTY_KEY PRTKEY ON PR.PRTY_RQST_ID = PRTKEY.PRTY_RQST_ID
JOIN PRTY_KEY_TYP PRKYTP ON PRTKEY.PRTY_KEY_TYP_ID = PRKYTP.PRTY_KEY_TYP_ID
WHERE (BIAP.BUSN_APPLC_NM = null )
OR (INTPTY.INTN_PROCES_TYP_NM = 'FulfillmentOrder')
OR (PR.UPDT_BY = 'update3')
OR (INSTS.INTN_STATS_NM = 'Submitted')
OR (PR.CHLD_RQST_IND = 'N')
OR (PR.TRACK_RQST_IND = 'Y')
OR (RQSTYP.RQST_TYP_NM = 'PensionPortfolioRebalance')
OR (RQSTYP.RQST_CLASS_NM = 'Composite')
OR (PRKYTP.PRTY_KEY_TYP_NM = 'NPIN')
OR (PRTKEY.PRTY_TYP_VAL = '101101' )
OR (ADDKEY.ADDTN_INFO_KEY_TYP_NM = 'PlanNumber')
OR (ADTINF.ADDTN_RQST_TYP_VALUE = 'TBMBUpdated');
AND (ADTINF.ADDTN_RQST_TYP_VAL_DT ='06-JUN-12 04.18.56.000000000 PM')
AND (ADTINF.ADDTN_RQST_TYP_VAL_NUM ='123123') ;
once again thank you all.But that's a completely different query than what was in the original post

Similar Messages

  • Need to pass out parameter in middle of a process. How can this be achieved

    Package test_pkg
    procedure main_prc(x_stat out varchar2)
    insert_prc(l_stat);
    x_stat:=l_stat;
    valid_prc
    end main_prc;
    procedure insert_prc(x_stat1 out varchar2)
         insert into staging table
         x_stat:='S';
    end insert_prc;
    procedure valid_prc
         validate staging table data
    end valid_prc;
    end test_pkg;
    Requirement: Need to pass out parameter in middle of a process. How can this be achieved?

    Use return at any time to get the out variable, but this will stop the process.

  • How can I pass multiple condition in where clause with the join table?

    Hi:
    I need to collect several inputs at run time, and query the record according to the input.
    How can I pass multiple conditions in where clause with the join table?
    Thanks in advance for any help.
    Regards,
    TD

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • Need to run the report for All Values when Null is passed in parameter

    Hi All,
    In my BIP report, I am using a parameter :asset with Type as Text, which means user will type the values for the parameter in the text box.
    Now, this parameter can take multiple comma separated values. I have a requirement to run the report for All Values when user doesn't enter any value in the parameter text box and if user enters any value(s) then the report will run for those values . The way, I tried to handle that in the query using couple of ways was :
    IMP : My Database is SQL Server
    where
    (table.asset = isnull((:asset), table.asset) or table.asset in (:asset))
    Now this works fine when I give a single asset number but when I give multiple values separated by comma like 123, 345 in the text box, then the statement fails saying 'encountered ,'
    I also tried simply
    table.asset in isnull((:asset),table.asset) -- but this doesn't work as it doesn't allow me to use in operater while using isnull and if i will use = operater then it won't work in case of multiple values
    Any suggestions on how can I handle this? Any help would be highly appreciated.
    Thanks,
    Ronny

    thanks for replying, but i tried this option too, it did not work for me, neither isnull nor coalesce. I mean, the solution work for single value but when i pass multiple values then separated by a comma then it doesn't work and shows me an error like "Incorrect Syntax ','". I am using SQL server as DB and bip is 10.1.3.4.1
    also please share the SR number, so i can also check the same.
    can there be any other work around to this?
    thanks,
    ronny

  • Passing multiple parameter to where condition

    Hi all,
    I want to pass multiple parameters to where condition.. it is as follows:
    i'll pass only TODAY date to M_DATE_TO variable.
    CURSOR C_COUNT(M_DATE_FROM  DATE, M_DATE_TO  DATE) IS
    SELECT COUNT (*)
    FROM table_name
    WHERE   TRUNC(table_name.join_date) BETWEEN M_DATE_FROM AND M_DATE_TO;
    begin
      SELECT TRUNC(LAST_DAY(ADD_MONTHS(:REP_VALUE_4,-1)))+1 INTO M_FIRST_DATE_MONTH FROM DUAL;
      SELECT TRUNC(:REP_VALUE_4, 'YEAR') INTO M_FIRST_DATE_YEAR FROM DUAL;
      SELECT TRUNC(ADD_MONTHS(:REP_VALUE_4,-12)) M_SAME_DATE_PYR FROM DUAL;
      SELECT TRUNC(LAST_DAY(ADD_MONTHS(:REP_VALUE_4,-13)))+1 INTO M_FIRST_DATE_MONTH_PYR FROM DUAL;
      SELECT ADD_MONTHS(TRUNC(:REP_VALUE_4,'YEAR'), -12) INTO M_FIRST_DAY_PYR FROM DUAL;
      M_DATE_FROM:=M_FIRST_DATE_MONTH;
      M_DATE_TO := TODAY;
      IF C_COUNT%ISOPEN THEN
      CLOSE C_COUNT;
      END IF;
      OPEN C_COUNT (M_DATE_FROM,M_DATE_TO);
      FETCH C_COUNT INTO M_COUNT_MTD;
      CLOSE C_COUNT;
      :cp_count_mtd:=m_count_mtd;
    M_DATE_FROM:=M_FIRST_DATE_YEAR;
    M_DATE_TO:= TODAY;
      IF C_COUNT%ISOPEN THEN
      CLOSE C_COUNT;
      END IF;
      OPEN C_COUNT (M_DATE_FROM,M_DATE_TO);
      FETCH C_COUNT INTO M_COUNT_YTD;
      CLOSE C_COUNT;
      :cp_count_ytd:=m_count_ytd;
    M_DATE_FROM:=M_FIRST_DATE_MONTH_PYR;
    M_DATE_TO:= M_FIRST_DAY_PYR;
      IF C_COUNT%ISOPEN THEN
      CLOSE C_COUNT;
      END IF;
    OPEN C_COUNT (M_DATE_FROM,M_DATE_TO);
      FETCH C_COUNT INTO M_COUNT_MTD_PYR;
      CLOSE C_COUNT;
      :cp_count_ytd_pyr :=m_count_ytd;
    Is there any easy way or other method, Please help me...Thanks in advance.
    Regi

    Thanks Roberto for reply.
    Please find the screenprint as per your suggestion. Also I have mentioned the code in above question. We are using the stored procedure to write the value into a table , passed from front end. We are able to write the value passed from front end into a table. So it means that system is passing the value.
    But when I try to bring same value into the data task flow , system is throwing a error. The description of error is also mentioned below.
    Kindly advise.
    Error Description in DM package:
    Description = Executing the query "exec dbo.sp_ver_copy2 'Account'" failed with the following error: "An error occurred while extracting the result into a variable of type (DBTYPE_STR)". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

  • Needs  help to retrive the last row in a  select query without using rownum

    Hi ,
    i need to retrive the last row from the select sub query without using rownum.
    is there any other way to retrive the last row other than the below query.
    is that the ROWNUM=1 will always retrive the 1 row of the select query ?
    select from*
    *(select ename from employee where dept_id=5 order by desc) where rownum=1;*
    Please advise.
    thanks for your help advance,
    regards,
    Senthur

    957595 wrote:
    Actually my problem is ithat while selecting the parents hiearchy of the child data using
    CONNECT BY PRIOIR query
    I need the immediate parent of my child data.
    For example my connect BY query returns
    AAA --- ROOT
    BBB --PARENT -2
    CCC --PARENT-1
    DDD IS my input child to the connect by query
    Immediate parent of my child data "DDD" ---> CCC(parent -1)
    i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
    I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
    So confusing with using this rownum in my query.
    Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
    you can select the PRIOR values to get the parent details if you want...
    SQL> ed
    Wrote file afiedt.buf
      1  select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
      2  from emp
      3  connect by mgr = prior empno
      4* start with mgr is null
    SQL> /
         EMPNO ENAME                                 MGR
          7839 KING
          7566   JONES                              7839
          7788     SCOTT                            7566
          7876       ADAMS                          7788
          7902     FORD                             7566
          7369       SMITH                          7902
          7698   BLAKE                              7839
          7499     ALLEN                            7698
          7521     WARD                             7698
          7654     MARTIN                           7698
          7844     TURNER                           7698
          7900     JAMES                            7698
          7782   CLARK                              7839
          7934     MILLER                           7782
    14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data)

  • PASS STRING IN TO WHERE CLAUSE

    Hi All,
    i'm facing a problem when i used
    SELECT * INTO TABLE ITAB FROM T000 WHERE T000~MANDT IN (810, 812, 800).
    then it's gives three values which is right according to requirement.
    but i hve to use a string n pass these values by string so i developed a string V_STRING N IT'S VALUE IS SAME AS 810, 812, 800.
    MEANS
    V_STRING = 810, 812, 800
    BUT WHEN I PASSED THIS STRING TO THIS SELECT THEN IT'S GIVE ONLY ONE VALUE FOR ONLY FIRST VALUE MEANS FOR ONLY 810.
    PLS SUGGEST ME WHY IT'S ONLY THROW ING RESULT ONLY FOR ONE VALUE.
    REGARDS,

    The only dynamic select is allowed by using an internal table of not more than 72 characters, so build the full string WHERE clause like:
    DATA: where_clause TYPE TABLE OF char72,
          clause LIKE LINE OF where_clause.
    PARAMETER p_mandt TYPE char50.
    CONCATENATE 'MANDT IN (' p_mandt ')' INTO clause.
    APPEND clause TO where_clause.
    and then
    SELECT * FROM t000  CLIENT SPECIFIED
      WHERE (where_clause).
    Remenber the limit of 72 char. So if only one field is of concern, you should better build a RANGE type internal table and use it in a IN logical expression of the WHERE clause. (Use SPLIT AT ',')
    DATA it_mandt TYPE TABLE OF char4 WITH HEADER LINE.
    DATA range_mandt TYPE RANGE OF t000-mandt WITH HEADER LINE.
    SPLIT p_mandt AT ',' INTO TABLE it_mandt.
    CLEAR range_mandt.
    range_mandt-sign = 'I'.
    range_mandt-option = 'EQ'.
    LOOP AT it_mandt.
      CHECK NOT it_mandt IS INITIAL.
      CONDENSE it_mandt.
      range_mandt-low = it_mandt.
      APPEND range_mandt.
    ENDLOOP.
    and then
    SELECT * FROM t000  CLIENT SPECIFIED
      WHERE mandt IN range_mandt.
    Regards

  • Use value from tabular form column in the LOV where clause of another column

    Hi
    Using APEX 4.2 on 11g
    In a tabular form I want to filter the values in a Popup Key LOV based on the value of another column (same row).
    i.e. I want to get the value of one column and use it in the where clause for the Popup LOV on the same row.
    e.g. where COL 2 is a popup LOV
    COL 1
    COL 2
    1
    LOV SQL: SELECT a FROM b WHERE c = <value from COL 1>
    2
    LOV SQL: SELECT a FROM b WHERE c = <value from COL 1>
    3
    LOV SQL: SELECT a FROM b WHERE c = <value from COL 1>
    The value in COL 1 does not change once the row is created. It is a hidden ID field.
    Is this possible?
    Nick

    Anyone have any ideas?
    I thought getting the value from one column and using it in another column would be commonly used functionality... I just can't seem to work it out.

  • What else is needed for pass CX-310-055?

    I have Mughals and Rasmussen's "A programmer's guide to Java Certification". for CX...-035, what else should I need to take the CX-310-055 exam?

    Practice Through Mock exams thats more better
    for You. The Book you refering is too good .

  • How to pass parameter in where clause in custom folder?

    I have the follow query
    blue color are the parameters
    i have paste this to a custom folder
    and
    select last_update_date, creation_date
    from ra_customer_trx_all
    where trunc(last_update_date)='29-SEP-2012'
    and customer_trx_id=1109
    to another custom folder returning 1 row only and create another worksheet in the same workbook and create
    3 parameter and 2 of them pointing to the 1 row query and create calcualtion
    SET_CONTEXT('Date_From',TO_CHAR(:Date From)) and SET_CONTEXT('Date_TO',TO_CHAR(:Date To))
    and 1 condition 1= SET_PARAM3(:Period)
    but this doesnt work for me, no data return please help
    select m.party_name TENANT_NAME 
    , b.interface_line_attribute10 lease_num
    --, b.interface_line_attribute12 "PPS Number" 
    ,b.interface_line_attribute2 LOCATION_CODE
    ,flexv.description property_name
    , a2.trx_number INVOICE_NUMBER
    --, t.name "Transaction Type" 
    --, e.attribute15 "AS400 Key" 
    , b2.description "BILL_ITEM_INVOCIE_DESCRIPTION" 
    ,case when gcc.segment5 like '6%' then 'P/L'
    when gcc.segment5 like '7%' then 'P/L'
    when gcc.segment5 like '8%' then 'P/L'
    when gcc.segment5 like '9%' then 'P/L'
    else 'B/S'
    end as account_nature
    --, gcc.concatenated_segments as "Charge Account" 
    ,gcc.segment1 company_code
    ,gcc.segment2 department_code
    ,gcc.segment3 property_code
    ,gcc.segment4 business_segment
    ,gcc.segment5 account_code
    ,gcc.segment6 project_code
    ,gcc.segment7 intercom_code
    ,gcc.segment8 spare1
    ,gcc.segment9 spare2
    , b2.extended_amount BILL_ITEM_INVOICE_AMOUNT
    ,to_char(substr(ps.gl_date,4,8)) gl_period
    , b.interface_line_attribute11 bill_start_date
    , b.interface_line_attribute14 bill_end_date 
    , decode(a2.invoicing_rule_id, '-2',  
       DECODE(TO_CHAR(b.RULE_START_DATE, 'YYYYMM'), to_char(to_date(to_char(TRUNC(to_date(SETPARAM.GET_PARAM3,'yyyymm') , 'Month')-1),'DD-MON-YYYY'),'YYYYMM'), 'Current', 'In Advance'), 
       'Current') bill_nature 
    , to_char(a2.trx_date, 'DD-MON-YYYY') invoice_date
    ,pal.lease_commencement_date
    ,pal.lease_termination_date
    ,h.user_name created_by
    --, NULL as remarks 
    from ra_customer_trx_all a 
    , ra_customer_trx_lines_all b 
    , pn_leases_all d 
    , pn_tenancies_all e 
    , hz_cust_accounts l 
    , hz_parties m 
    , fnd_user h 
    , ar_payment_schedules_all ps 
    , RA_CUST_TRX_LINE_GL_DIST_ALL dist 
    , gl_code_combinations_kfv gcc 
    , AR_RECEIVABLE_APPLICATIONS_all app 
    , ra_customer_trx_all a2 
    , ra_customer_trx_lines_all b2 
    , RA_CUST_TRX_TYPES_all t 
    , fnd_flex_values_vl flexv
    ,pn_lease_details_all pal
    where  
    app.APPLICATION_TYPE = 'CM' 
    and flexv.flex_value=gcc.segment3
    and flexv.FLEX_VALUE_SET_ID=1014916
    and pal.lease_id=d.lease_id
    and app.applied_customer_trx_id = a.customer_trx_id 
    and app.customer_trx_id = a2.customer_trx_id 
    and a2.cust_trx_type_id = t.cust_trx_type_id(+) 
    and a2.org_id = t.org_id(+) 
    and b.customer_trx_line_id = b2.previous_customer_trx_line_id 
    and dist.CUSTOMER_TRX_LINE_ID = b2.CUSTOMER_TRX_LINE_ID 
    and dist.account_class = 'REV' 
    and dist.account_set_flag = DECODE(NVL(a2.invoicing_rule_id,1), -2, 'Y', 'N') 
    and gcc.CODE_COMBINATION_ID(+) = dist.CODE_COMBINATION_ID 
    and b.interface_line_attribute10 = d.lease_num 
    and d.lease_id = e.lease_id 
    and e.primary_flag = 'Y' 
    and b2.customer_trx_id = a2.customer_trx_id 
    and a2.bill_to_customer_id = l.cust_account_id 
    and l.party_id = m.party_id 
    and a2.created_by = h.user_id 
    and ps.customer_trx_id = app.customer_trx_id 
    and ps.gl_date between trunc(trunc(TO_DATE(SYS_CONTEXT('DISCO_CONTEXT','Date_From')),'MM')-1,'MM') and trunc(TO_DATE(SYS_CONTEXT('DISCO_CONTEXT','Date_To')),'MM')-1

    What exactly is wrong with the results? Can you make the report include the gl_date so that you can see exactly what is being included?
    The only way to troubleshoot this is to go back to basics. You have to be 100% certain that the parameter and calculations for the dates are working. You have granted execute permission over the function to your EUL owner - yes? What I did was create the function in a package owned by EUL_US then I had no issue with grants or permissions.
    Also, gl_date is a DATE and not a string right? I ask because if it is not a date but a string then some dates might be left out.
    Assuming you are 100% certain of the building blocks you should start by including only the gl_date and primary key from the table you are using. Once you are sure you are getting the right data you can start to add in more fields.
    I do notice you are using E-Business Suite objects. I copied the code into my system where I am not using leasing. So I commented out the references to the 3 PN tables. I got 150 rows of data when I queried using the parameter and again when I hard coded the BETWEEN for the gl_date. You do have to make sure that your EUL owner has been granted SELECT right from all the tables and views used in your code and, if you intend to share this code with someone else, you will also need to have GRANT rights.
    Try your code in a SQL tool such as TOAD and see what happens. Are you absolutely sure that every one of your transactions has an entry in the PN tables? This might be why you are not getting the results you expect. You could try, as I did, to comment those lines out and then see what happens.
    Hope this has given you enough to solve your issue
    Michael
    PS. It would be nice to know your name. You haven't used it once in your thread.

  • Passing URL Parametes to Variables in variable Selection Screen

    Hi
    Is there any way to pass the URL parameters to the variables in the selection screen of Web Report/ and How to make to non editable.
    Your points are assured
    Thanks and Regards
    Prasad

    Pankaj,
    What you have mentioned is for BSP Pages... for web reports .. add the following to the URL..
    &CMD=PROCESS_VARIABLES&SUBCMD=VAR_SUBMIT&VAR_NAME_1=<Your Variable Name>&VAR_VALUE_EXT_1=<Value of the variable>
    This is for a normal variable - it is slightly different for hierarchy variables...
    For details information - you can refer the WEB API reference 3.x....
    service.sap.com/bi -> BW infoindex -> Web Application Designer 3.x -> Web API Reference 3.5 (pdf)
    Arun
    Assign points if useful
    Message was edited by:
            Arun Varadarajan

  • Need single record for single period. Modify the select query.

    Requirement
    THere are 6 programs for each company for each billing period. If anyof the program for one billing period and period_balance>0 then display outstanding balance YES. if period_balance <=0 for all the programs for one period then outstanding balance=NO
    Below is the query i have used but i have to modify the query to get single record for each period whether outstandignbalance yes or no. Please help to resolve this issue. OR modify the query.
    select distinct B_Billing_key, B_COMPANY_ID company ,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) lastPaymentdate,
    SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,AMOUNT,
    (nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))"Period_Balance",
    decode(sign((nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))),1, 'Yes'
    ,'No'
    ) outstandingbalance
    p.PROGRAM_NAME_ID programname
    FROM tuff_balance_view,MV_PROG_SURCH S,MV_PAYMENT_HOLDING H,MV_PROGRAM_DICT P where
    b_company_id = 'U-7052-C'
    and B_Billing_key=s.BILLING_KEY
    and S.PROGRAM_KEY = P.PROGRAM_KEY
    and P.PROGRAM_KEY= H.PROGRAM_KEY
    GROUP BY B_Billing_key,B_COMPANY_ID,B_REPORT_PERIOD,SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,PROG_SURCH_KEY,
    S.PROGRAM_KEY,p.PROGRAM_NAME_ID,AMOUNT
    order by B_Billing_key desc
    B_Billing_key is the primary key. I am looking for the output only one record for each biling perid. there are 6 programs for each billing period. if any of the program has period balance >0 then outstanding balance should be yes. For sample i am giving 2 programs.
    Actual output from the above
    biling_key company billing period period_balance outstandingbalance programname
    123 xyz January 2011 $4 Yes ABC
    123 xyz January 2011 $-5 NO DEF
    456 xyz February 2011 $-3 NO ABC
    456 xyz February 2011 $- 2 NO DEF
    Need the output as below from the above query. Can you please help to simplify query. If anyof theprogram having outstanding balance for that particular period show the outstandigbalance as yes. Else NO.
    Expected output as below
    company billing period outstandingbalance programname
    xyz January 2011 Yes ABC
    xyz February 2011 No DEF
    Thanks,
    vi

    Hi G,
    With the same query i am gettting outs as NO for all months which is not true. can you pelase look at the following data.
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc
    Actual
    Billing key Billing company periodbalance lastpayment date outs
    110631534073     November 2010     U-7052-C     270          Yes
    110631534073     November 2010     U-7052-C     690          Yes
    110631534073     November 2010     U-7052-C     66          Yes
    110461533197     October 2010     U-7052-C     4740          Yes
    110461533197     October 2010     U-7052-C     27000          Yes
    110461533197     October 2010     U-7052-C     0          No
    110251532527     September 2010     U-7052-C     0     09/13/10     No
    110251532527     September 2010     U-7052-C     0          No
    110251532527     September 2010     U-7052-C     -18     09/13/10     No
    110251532484     August 2010     U-7052-C     0     09/13/10     No
    110251532484     August 2010     U-7052-C     2001     09/13/10     Yes
    110251532484     August 2010     U-7052-C     0          No
    Expectedoutput(need only following columns)
    Billing key Billing company lastpayment date outs
    110631534073     November 2010     U-7052-C               Yes
    110461533197     October 2010     U-7052-C               Yes
    110251532527     September 2010     U-7052-C          09/13/10     No
    110251532484     August 2010     U-7052-C          09/13/10     YES
    By using below query i am getting all output as NO. HOw to modify it.
    SELECT company,
    billing,LastPaymentDate,
    CASE
    WHEN SUM (DECODE (outs, 'YES', 1, 0)) > 0 THEN 'YES'
    ELSE 'NO'
    END Outstanding
    FROM (
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc)
    GROUP BY company, billing,LastPaymentDate;
    Note:in the actual out put max(lastpayment date) is returing null values. if there is any date in one billing return that date only remove null example is september. in september it should return only 09/13/10 this date not null date. but if there is no other within one biling then consider that as null example november..
    Thanks,
    v

  • PL/SQL: how to use in parameter in select sql where clause

    Hi
    in a procedure, I need to apply 'in parameter' in 'where clause' along with other table fields. Purpose is to create dynamic select querry with multiple conditions.
    select count(*) from table xx
    where y_code=2008 and v_type in ('SI', 'TI', 'DI') ;
    my requirement is replace 'and v_type in ('SI', 'TI', 'DI')' with in parameter. pls note in paramter may contain null value.
    Regards

    ... e.g. why on earth do you want to pass in a string to be appended to the WHERE clause of an SQL.I second that and I strongly advice NOT to do it. If you really want to do it, then come back and show us, how you would prevent SQL injection. This approach is too dangerous (and too complex) IMHO.
    Do it straight forward as in the article of Tom Kyte (link in the post of BluShadow above)

  • How to pass a parameter with more than one value to a report? (urgent)

    Hi, all
    I try to pass a parameter from a search form to a report in
    which I would like to print out my search result. My problem is
    I can pass the parameter to report but only one value which my
    cursor points to. could anyone tell me how to pass a list of
    value to the report? my trigger in form like this:
    declare
    PL_ID PARAMLIST;
    sc_no books.c_no%type;
    begin
    PL_ID := GET_PARAMETER_LIST('parametername');
    IF NOT ID_NULL(PL_ID) THEN
    DESTROY_PARAMETER_LIST(PL_ID);
    END IF;
    PL_ID := CREATE_PARAMETER_LIST('parametername');
    IF ID_NULL(PL_ID) THEN
    MESSAGE('PL/SQL held against Button failed to execute');
    RAISE FORM_TRIGGER_FAILURE;
    END IF;
    ADD_PARAMETER(PL_ID, 'PARAMFORM', TEXT_PARAMETER,'NO');
    sc_no := :searchlist.c_no; --(c_no is the value I want to pass
    but not only one.)
    ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
    RUN_PRODUCT(REPORTS, 'reportpathname.rep', SYNCHRONOUS, RUNTIME,
    FILESYSTEM, PL_ID, NULL);
    end;
    Thank you in advance
    Diana

    Is it your values in parameter NO separated by coma? And is it
    parameter in where clause?
    Do you want something like :
    from table
    where s_no in (NO) ?
    If is answer "yes" you can create lexical parameter in report.
    You can write in report sowething like:
    select a.field1, a.field2,.....
    from table a
    &COND /* this is if is condition only one line after "from".
    if you have more lien after where then you will put this &COND
    in line where you want to have your multivalue.
    Then in your trigger in form you should write:
    sc_no := 'where a.sc_no in ('||:searchlist.c_no||')';
    ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
    /* again this is if you have only one line with WHERE ili
    conditions */
    or you will write:
    sc_no := 'and a.sc_no in ('||:searchlist.c_no||')';
    ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
    It will substitute line in which is your conditions with
    multivalue.

  • 'BAPI_ISUCONTRCT_CHANGEFROMDATA'   what all paremetes i need to pass

    Hi Experts,
    In
    'BAPI_ISUCONTRCT_CHANGEFROMDATA'   what all paremetes i need to pass in import structure
    contractdata =            
    contractdatax = 
    in contractdata i am passing vertrag  what else i need to pass in this structure
    , in contractdatax all parameters are size of characters 1
    Thanks

    That bapi doesn't have the instructions on the documentation - but look at another one to find out how to use bapis - or check with your technical team, as bapi usage is standard functionality.
    regards,
    bill.

Maybe you are looking for

  • Upload into Database

    Hi, I'm trying to find out how the PL/SQL "procedure upload" actually uploads a file from a users hard disk into a remote database. I presume this doesn't use ftp, but some other mechanism. Can anyone shed any light on this please? TIA - Julian.

  • Why  wait  and notify kept in object class only

    why wait and notify kept in object class only. is it maintain locks while doing wait and notify . please explain internals,

  • DNG profile with Fuji X100s raw files...

    Hi, I'm trying to make a dng profile for my Fuji X100s (I did the same recently for my Canon 5dII). Because I shoot architecture and interiors, I profiled for daylight, tungsten, and flourescent light (I also did this for the Canon with success, much

  • Lenovo yoga 2 display

    I just bought my yoga 2 pro a few days ago and started watching a movie on netflix. I was watching the avengers and noticed that the image was very blurry. Does anyone else notice images being blurry when watching a movie? Just wondering if thats nor

  • Why can't I read email (Novell)

    When I try to read or send email from my Novell site I get a message to turn off pop up blocker. Where do I do this.