Conditional columns  query

hi
Iam trying to write a query which is as follows
select A1,A2,A3,A4,A5,A5,A6,A7 from table.
such that columns A1,A2,A3 must be displayed only when A1 is not null
and columns A4,A5,A6 must be displayed only when A4 is not null.
any help..
thanks
Kumar

Alternatively:
SELECT NVL2(a1, a1, NULL) a1, NVL2(a1, a2, NULL) a2, NVL2(a1, a3, NULL) a3,
       NVL2(a4, a4, NULL) a4, NVL2(a4, a5, NULL) a5, NVL2(a4, a6, NULL) a6
FROM <table_name>;NVL2 demos here:
http://www.morganslibrary.org/reference/misc_func.html#mfn2
SQL> create table test1 (
  2  a1 number,
  3  a2 number,
  4  a3 number,
  5  a4 number,
  6  a5 number,
  7  a6 number);
Table created.
SQL> insert into test1 values (NULL,1,1,1,1,1);
1 row created.
SQL> insert into test1 values (1,1,1,NULL,1,1);
1 row created.
SQL> insert into test1 values(1,1,1,1,1,1);
1 row created.
SQL> set timing on
SQL> DECLARE
  2  CURSOR casecur IS
  3  SELECT  (CASE WHEN A1 IS NOT NULL THEN A1 END) AS A1
  4  ,       (CASE WHEN A1 IS NOT NULL THEN A2 END) AS A2
  5  ,       (CASE WHEN A1 IS NOT NULL THEN A3 END) AS A3
  6  ,       (CASE WHEN A2 IS NOT NULL THEN A4 END) AS A4
  7  ,       (CASE WHEN A2 IS NOT NULL THEN A5 END) AS A5
  8  ,       (CASE WHEN A2 IS NOT NULL THEN A6 END) AS A6
  9  FROM test1;
10  BEGIN
11    FOR i IN 1 .. 100000 LOOP
12      FOR caserec IN casecur LOOP
13        NULL;
14      END LOOP;
15    END LOOP;
16  END;
17  /
PL/SQL procedure successfully completed.
Elapsed: 00:00:06.67
SQL> DECLARE
  2  CURSOR casecur IS
  3  SELECT NVL2(a1, a1, NULL) a1, NVL2(a1, a2, NULL) a2, NVL2(a1, a3, NULL) a3,
  4         NVL2(a4, a4, NULL) a4, NVL2(a4, a5, NULL) a5, NVL2(a4, a6, NULL) a6
  5  FROM test1;
  6  BEGIN
  7    FOR i IN 1 .. 100000 LOOP
  8      FOR caserec IN casecur LOOP
  9        NULL;
10      END LOOP;
11    END LOOP;
12  END;
13  /
PL/SQL procedure successfully completed.
Elapsed: 00:00:06.62
SQL> I don't think it is going to much matter which you choose.

Similar Messages

  • Conditional Column Formatting in an Interactive Report?

    Is it possible to add conditional column formatting in an Interactive Report in Apex 4.1? I've found numerous examples for older versions using the standard (classic) report, but I haven't found any with the new Interactive Report. Is this possible? and if so, can someone point me in the direction of some documentation or examples?
    I simply want to change the color of the text depending on whether a column has a value (eg. Error or Problem).
    Thanks

    JB wrote:
    Is it possible to add conditional column formatting in an Interactive Report in Apex 4.1? I've found numerous examples for older versions using the standard (classic) report, but I haven't found any with the new Interactive Report. Is this possible? and if so, can someone point me in the direction of some documentation or examples?
    Oracle Application Express (APEX)
    As interactive reports lack the HTML Expression feature of standard reports, the simple way to do this unfortunately requires violating the separation of concerns and generating structural (a <tt>span</tt> element) and presentational (an in-line style sheet) aspects in the query:
    select
    ⋮        
           , case
               when trunc(calling_date,'DD') =  trunc(sysdate,'DD')
               then
                 '<!-- ' || to_char(calling_date, 'YYYYMMDD') || ' --><span style="color: #3399FF;">' || to_char(calling_date) || '</span>'
               else
                 '<!-- ' || to_char(calling_date, 'YYYYMMDD') || ' --><span>' || to_char(calling_date) || '</span>'
             end calling_date
    ⋮For number/date columns to be properly sortable, the leading edge of the column must be an HTML comment that provides the required sort order using character semantics, as shown here.
    The Display As column attribute for such columns must be set to Standard Report Column.
    This method has side effects: some IR filters won't work; aggregate calculations can't be applied to the column; and report exports contain the HTML rather than the expected value.
    Other approaches involve using Dynamic Actions/jQuery/JavaScript, or using the built-in highlight as suggested above, then saving the highlighted report as the default.

  • How to Use MAX condition using Query Report

    Hi SAP Abap Expert,
    Can we use the MAX condition in Query Report (SQ01/SQ02) ?
    I have created one sample query using table VBRP and VBRK then i need to use max condition to get the MAX record in VBELN.
    Please Help ???

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • What is the use of Condition is Query Designer  ??

    What is the use of Condition in Query Designer  ??
    How to use condition in   Query Designer  ??

    Hi,
    Conditions in a query can be defined for both characteristic combinations and key figures.
    Characteristic combinations can be used using the ranking list functionality (e.g Top N or Last N customers with highest sales).
    Key figures can be assigned the value limit conditions ( for e.g. display only rows in the query for which the key figure > 10 ).
    For your specific requirements in which you need to display only a limited set based on the key figures, then you can go for conditions.
    The conditions can be allowed to work on all the drill down characteristics independently, single characteristics or combination as well based on your requirement.
    While execution the report, you can activate or deactivate the condition anytime by right clicking on the data cells.
    Regards,
    VA

  • Trouble executing data found on TABLE: exe_sel_dttime_xml (COLUMN: QUERY)

    Hello,
    I want to execute using EXECUTE IMMEDIATE the data found on a table
    exe_sel_dttime_xml
    The following code inside a PLSQL procedure constantly gives me coding problems(therefore not working as it should!!):
    BEGIN
    FOR r
    IN (SELECT QUERY INTO v_toexecute FROM exe_sel_dttime_xml)
    LOOP
    EXECUTE IMMEDIATE v_toexecute;
    END LOOP;
    END;
    Basically what this code is supposed to do is execute each of the data found inside the COLUMN: [QUERY] found on the TABLE: [exe_sel_dttime_xml]
    ie,
    SQL> r
    1 select * from exe_sel_dttime_xml
    2*
    QUERY
    SELECT COL_TNAME, DEVICE_DTTIME
    INTO table_dttime(COL_TNAME, COL_DTTIME)
    FROM t_xml_01;
    SELECT COL_TNAME, DEVICE_DTTIME
    INTO table_dttime(COL_TNAME, COL_DTTIME)
    FROM t_xml_02;
    SELECT COL_TNAME, DEVICE_DTTIME
    INTO table_dttime(COL_TNAME, COL_DTTIME)
    FROM t_xml_03;
    SELECT COL_TNAME, DEVICE_DTTIME
    INTO table_dttime(COL_TNAME, COL_DTTIME)
    FROM t_xml_04;
    SELECT COL_TNAME, DEVICE_DTTIME
    INTO table_dttime(COL_TNAME, COL_DTTIME)
    FROM t_xml_05;
    SELECT COL_TNAME, DEVICE_DTTIME
    INTO table_dttime(COL_TNAME, COL_DTTIME)
    FROM t_xml_06;
    Remember,
    I need this to work using the following:
    + EXECUTE IMMEDIATE
    + Querying the data from table: exe_sel_dttime_xml
    (ie, SELECT QUERY INTO v_toexecute FROM exe_sel_dttime_xml)
    All (and any) help is appreciated
    -ng

    first thing, when writing cursor for loop, the select statement does not have to contain the INTO clause.
    for rec in (select ename from scott.emp)
    loop
      dbms_output.put_line(rec.ename) ;
    end loop ;Next, can you execute the select statements stored in the table exe_sel_dttime_xml at the SQL*Plus prompt?
    if you cannot, you cannot do execute immediate on them.
    if the table_dttime is a table in the database into which you are inserting the data selected from the table t_xml_01, then it should be coded as a
    insert into ... select ...
    statement.
    explain in detail what you are trying to do and someone can help you.

  • Tabular Form: Conditional column based on another column in table/form?

    Hi!
    I have 4 columns in table A:
    number (the question number)
    question (the question to be asked)
    type (TEXT, LOV are the 2 valid values)
    answer (the answer with text or a selection from the lov table below)
    I have 2 columns in table B:
    number (the question number)
    values (a single value for the lov's)
    In table B there can be mutiple rows for each number. Table A and table B
    join on the number.
    I want to build a tablular form on table A where for each row either a text
    box or a select list is displayed depending on the contents of the type column.
    So row 1 would display a text box when the type value is text; row 2 would
    display a select list when the type value is lov.
    Is this even possible? How do I refer to the type column in the conditional for the
    answer column? I am guessing that I will need to have 2 answer columns one
    that displays when the type column is TEXT and one that displays when the
    type column contains LOV. This is OK. Setting up the conditional is display is the issue at this point.
    Hopefully I have explained this well enough! :)
    Thanks!
    Dave Venus

    Hi Dave,
    Sorry for not responding sooner - I finish work at 3pm GMT.
    I'll take your first question first (3:28PM posting according to my display - not sure if you are on GMT time?):
    As far as I understand it, using the select_list_from_query() function generates the options that are required in the select list as HTML tags. Each instance of this function should create a SELECT tag and the results of the query should generate one or more OPTION tags within it.
    Second question (4:20PM posting):
    The HTMLDB_ITEM functions are listed in the documentation - here's a link to the online version:
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14303/api.htm#sthref2524
    Most of the examples that I have seen have been on this forum - simply search for HTMLDB_ITEM or one of its functions.
    I tend to leave the generation of tabular forms to the wizard as much as possible. The only exceptions are when I need to have access to more than the Primary Key for a row but don't want to show the field on screen. There are examples on the forum about concatenating the HTMLDB_ITEM functions into a single value - this hides ID fields from the user but makes them available to PL/SQL code.
    Third question (5:29PM posting)
    I did try using DECODE in my questionnaire but not for the feature that you needed. Originally, I wanted to use this to display one of a number of different fields (ie, my date, number or string field as appropriate to the question) but this didn't help as I couldn't get back to the right field during the update. If you have decode working for the select lists, then that's great!
    The first column should be hidden or sitting behind a checkbox as this should be the Primary Key for the row and should not be editable by the user nor would it normally be displayed.
    As long as your select statement creates the correct output (albeit that you may need to work on the layout!), you should have an updatable form. However, you will need to have the MRU processes in place and the appropriate buttons that trigger these. When I did my questionnaire, I created the form using a wizard to get all of the processes and buttons and then changed the select statement. If you haven't got the processes and/or buttons, we can go through adding these onto your page.
    Last question (9:08PM posting)
    As explained above, column 1 should normally be hidden. The INPUT tag you detail above is what I would expect to see. The value="6" attribute indicates that 6 is the Primary Key for that row - every row will have the same tag but different values for the "value" attribute. So, if it is hidden and these are the tags you see doing a View Source on the page, then everything is correct.
    OK. So now we have the data on screen and (hopefully?) we have the correct processes and buttons on the page.
    The next step would be validation and update of the data.
    Validation of the data can be handled by a normal page process - I can let you have example code if you want to validate the data (this will also explain how to loop through the rows - there are also methods that you can use to do this in javascript if you want). Updates should be handled by the processes and buttons on the page - again, if you haven't got these we can go through adding them in (although, if you haven't yet formatted your page, you may find it quicker to copy your select statement and create the page again using the same select statement).
    ORA-20001 errors are user defined errors. Do you mean the "data has changed" errors? If so, you will probably need to include the MD5 checksum functionality (it's shown in the document linked above).
    Finally, we'll keep this thread going so that you have all of your workings and my responses in one place, if that's ok with you?
    Regards
    Andy

  • Conditional Columns in Select Statement for any type of Report

    Okay so I had a requirement to conditionally show columns on a report when the data in the column was not null. I played around the "vertical" report mentioned in other posts but it didn't work well for my needs. Also I know that there is a javascript solution for this as demonstarted in Denes Kubicek's app (which was copied from Vikas :) ). Anyways listed below is my approach.... Hope this can help anyone else out as it's just pl/sql returning sql. Also you will need execute on dbms_sql for this to work.
    declare
    v_count number := 0;
    v_row_count number := 0;
    v_col_name varchar2(100);
    q varchar2(4000) := 'select ';
    v_table_name varchar2(100) := :SOME_TABLE_NAME;
    v_id varchar2(100) := 'num = '||:SOME_APEX_VALUE;
    my_c INTEGER;
    fdbk INTEGER;
    statement varchar2(2000);
    cval_out varchar2(2000);
    nval_out number;
    begin
    select count(*) into v_count from cols
    where table_name = v_table_name;
    for counter in 1..v_count
    loop
    select column_name into v_col_name
    from cols where table_name = v_table_name
    and counter = column_id;
    statement := 'select count(*) '||
    ' from '||v_table_name||
    ' where '||v_col_name||' is not null and '||v_id;
    my_c := dbms_sql.open_cursor;
    dbms_sql.parse(my_c,statement,dbms_sql.native);
    dbms_sql.define_column(my_c,1,nval_out);
    fdbk := dbms_sql.execute(my_c);
    LOOP
    exit when dbms_sql.fetch_rows(my_c) = 0;
    dbms_sql.column_value(my_c,1,nval_out);
    end loop;
    v_row_count := nval_out;
    dbms_sql.close_cursor(my_c);
    if v_row_count > 0 then
    q:=q||v_col_name||',';
    end if;
    end loop;
    if(substr(q,length(q),1) = ',') then
    q:= substr(q,0,length(q)-1);
    end if;
    q:= q||' from '||v_table_name||' where '||v_id;
    end;Hope this helps...
    -David
    Message was edited by:
    rdpatric

    Hi Gints,
    Thank you for your reply. This is my query and
    nvl(TICKET_JOIN.TDQRLV,0) ACC_SHIPPED_QTY,
    TICKET_JOIN.TDSOQS QUANTITY_TICKETED are the columns tha's creating issue. If I comment those columns Index is accessed properly.
    select
    'TKT' SOURCE,
    TICKET_JOIN.TKDO01 HIRE_ID,
    TICKET_JOIN.TKQ101 TRUCK_ID,
    TICKET_JOIN.TKVEHT TRUCK_TYPE,
    1 TRUCK_COMM,
    nvl(TKCMP1,0) TICKET_NUM,
    nvl(TKADTM,0) TICKET_TIME,
    --TICKET_JOIN.TDSOQS QUANTITY_TICKETED,
    0 CHECKIN_TIME,
    --nvl(TICKET_JOIN.TDQRLV,0) ACC_SHIPPED_QTY,
    nvl(DDADTM,0) START_TIME
    from
    (select
    TICKET.TKCMP1,
    TICKET.TKDO01,
    TICKET.TKQ101,
    TICKET.TKADTM ,
    TICKET.TKVEHT,
    TICKET_DETAILS.TDAITM ,
    TICKET_DETAILS.TDQRLV ,
    TICKET_DETAILS.TDSOQS ,
    TICKET.TKCNTF,
    TICKET.TKTRDJ,
    TICKET.TK58GA8
    from
    CRPDTA.F5800091 TICKET_DETAILS ,
    CRPDTA.F5800090 TICKET
    where TICKET.TKCMP1 = TICKET_DETAILS.TDCMP1
    and TICKET.TKTRDJ = TICKET_DETAILS.TDTRDJ
    and TICKET.TKTRDJ = 107085
    and TICKET.TKEV12 <> 'Y'
    and TICKET.TK58GA8='ECSEO'
    and TICKET.TKCNTF = '11') TICKET_JOIN ,
    (select
    DDDOCO,
    DDCNTF,
    DDQTFN,
    DDAITM,
    DDADTM,
    DD58GA8,
    DDTRDJ
    from
    CRPDTA.F5800051 ORDER_DETAILS,
    CRPDTA.F5800050 ORDER_HEADER
    where
    ORDER_HEADER.DHDOCO = ORDER_DETAILS.DDDOCO
    and ORDER_HEADER.DHTRDJ = ORDER_DETAILS.DDTRDJ
    and ORDER_HEADER.DH58GA8 = ORDER_DETAILS.DD58GA8
    and ORDER_HEADER.DHDCTO = ORDER_DETAILS.DDDCTO
    /*and
    (ORDER_HEADER.DHTRDJ = 107085
    OR (ORDER_HEADER.DHTRDJ = 107084 and ORDER_HEADER.DHEV04='Y')
    and TRIM(ORDER_HEADER.DH58GA8) = 'ECSEO'
    and TRIM(ORDER_DETAILS.DDCNTF) = '11' ) ORDER_VIEW
    where TICKET_JOIN.TKTRDJ = ORDER_VIEW.DDTRDJ
    and TICKET_JOIN.TDAITM = ORDER_VIEW.DDAITM
    and TICKET_JOIN.TKCNTF = ORDER_VIEW.DDCNTF
    and TICKET_JOIN.TK58GA8 = ORDER_VIEW.DD58GA8
    and NOT EXISTS ( select 1 from CRPDTA.F5800120 TRUCK_ASSIGNMENT
    where TATRDJ = 107085
    and TACNTF = '11'
    and TA58GA8 = 'ECSEO'
    and TICKET_JOIN.TKQ101||TICKET_JOIN.TKVEHT = TAQ101||TAVEHT )
    Thanks
    GM

  • Use of Conditions in query

    Hi,
         While using conditions, there are 2 options mentioned
    1.all the characteristics in the drill down independently
    2.Single characteristics or combination of characteristics
    Can someone explain me the above two with examples?

    Hi,
    This property would allow to choose if we would like to apply the conditions to all the characteristics or particular characteristic.
    Typically we select - All Characteristics in the Drilldown Independently
    This setting allows you to apply a condition in a general way. Depending on which characteristics you use in the drilldown, you obtain different results.
    Single Characteristics and Characteristic Combinations
    This setting allows you to evaluate the condition for characteristics or characteristic combinations defined for specific drilldowns only. You can select any characteristic (of the characteristics used in the query in rows, columns, or in the free characteristics) or a characteristic combination.
    Thanks.

  • Reports - Passing checkbox values and conditional column visibility

    Although I've been using Oracle databases for many years, I've to admit I'm rather new to APEX. I'm building a first prototype project to convince our project leaders and managers of the usefulness of the product for future projects (as for visual Database interfaces where the accent is on forms and reporting, it will often be faster and less expensive to build an APEX application instead of a full blown Java or C# webapp).
    I'm however encountering some problems.
    Let me start with a quick description. I've the following parent/child structures:
    Provinces > Cities > Intersections > Loops > Loop Detections.
    I basically want to make a report on the loop detections. Now, considering we'll have many thousands of detections a day, I made kind of a drilldown structure. You first choose your province, then the city, then the intersection and finally the loop. I didn't use lists to make the selection. Instead I made a (classic) report for each part as this allows me to give detailed information for each part. In each report, I made a link on the identifier. For example, when I select a province (by clicking on the link), I pass the province identifier to the cities report and use it in the query to limit my report to those cities for the given province. I repeat these step for the different parts, which in the end, gives me the loop detections for the selected loop. The good news is all this works fine. The person who'll be using this application however made a suggestion and asked if it would not be possible to select different loops and as such get the detections for several loops (the rest of the application stays the same). This however means I cannot use the column link anymore. Now, I was thinking in the direction of a checkbox. The column link is still there, but the user would also have the possibility to select several items in the report. I managad to add a checkbox to the report, linked to the loop identifier column. That's not exactly difficult. I cannot figure out however, how I can pass the selected identifiers to the next report (detections for the selected loops) and use it in the underlaying query of this report. The problem is, I don't know how to pass the checked values to the next page and how to use these values in the report query of that page. I suppose this must be possible, but I couldn't figure out how. I tried playing around with APEX_APPLICATION.G_Fxx and such. Remember I'm a newbie and this seems to fall under more advanced features.
    I've uploaded images of the 2 concerning report pages for illustration:
    http://img96.imageshack.us/img96/1497/apex01.jpg
    http://img140.imageshack.us/img140/9868/apex02.jpg
    A second point that's bothering me is the following. In the loop detection report I show a colum link (I picked an icon instead of the column value) for each row. I also have a column that shows the number of detections for the given loop (and day). Now, for some loops, there are no detections for that given day. As such, there's no point in selecting this loop, as the result will be an empty report. However, I still want to show the loop in the loop selection report, as it's still present (it's not as if it suddenly disappeared). Sure, no big problem and most users probably have sufficient intelligence to figure this out. However, it would be nice if I could make the icon (colum link) visible only for those loops that have detections, or in other words, for those records where number_of_detections (underlaying column COUNT) is greater than 0. I couldn't figure out a way to do this either. The Conditional Display option for a column didn't really offer me a solution here.
    Before I forget, I'm using APEX 4.0.1 on an Oracle XE database.
    Any tips or suggestions would be welcome! :)
    Thanks.
    Erwin

    Hi,
    You mean something like in this sample
    https://apex.oracle.com/pls/otn/f?p=40323:55
    You can store checked values to collection and use it then in another report where clause
    See e.g. this post for how you can store checked rows to collection
    Re: Need help with APEX_Collection
    In sample DEPT report query is
    SELECT
      CASE WHEN EXISTS(SELECT 1 FROM emp e WHERE e.deptno = d.deptno) THEN
        APEX_ITEM.CHECKBOX(1,c.c002,'onclick="saveDeptChk(this,'||c.seq_id||')"','true')
      END AS row_selector,
      c.c002 AS checked,
      d.DEPTNO,
      d.DNAME,
      d.LOC
    FROM dept d,
      apex_collections c
    WHERE c.collection_name = 'DEPT_CHK_COLLECTION'
      AND d.deptno = c.c001And EMP report
    SELECT e.EMPNO,
      e.ENAME,
      e.JOB,
      e.MGR,
      e.HIREDATE,
      e.SAL,
      e.COMM,
      e.DEPTNO
    FROM emp e,
      apex_collections c
    WHERE c.collection_name = 'DEPT_CHK_COLLECTION'
      AND c.c002 = 'true'
      AND e.deptno = c.c001Regards,
    Jari

  • Issue with condition in Query

    Hi,
    I have report on a cube which when  execute vit all main characteristics(highest level char[plant] to lowest level[material] chars) like plant, external-material grp, material type, project-plant and material the report vil come vit correct values , wen v remove the lowest level ie., material the overall result is changing.
         There is a condition for Godown Quantity(godown qty notequalto  0)
        Because of the condition on godown qty the overall result is changing.
    like:
    qty 61-120amt 61-120qty >120----amt >120
    10936.06-766957.91-1955762.54--725613332.2(overall-results)
    when we drill down are remove drill down any characteristic then some value(6422) of amt61-120 days  is shifting to amt>120days,this happening  also for qty.
    like:
    10934.66760535.291955763.94---725619755(overall-results)
        so i removed the condition and executed the report, here wat ever char v remove and wat ever char v drill down no effect to over all result means it vil remain unchange.
       But asking for no zero values for Godown quantity.
    Help me in this....
    Thanks in Advance,
    Chaitu.
    Edited by: chaithu218 on Jun 6, 2011 5:09 PM

    Hi,
    user555994 wrote:
    Hello Lee,
    thanks for your reply.
    But what is B?I think Lee meant to name the in-line view "B", like this:
    SELECT b.app_req_id
    FROM  (SELECT   a.app_req_id,
                    COUNT(*) cnt       -- or maybe COUNT (DISTINCT a.class_symbol)
           FROM     app_req a
           WHERE    a.class_symbol IN ('MBA', 'BTECH', 'BBA', 'SENIOR SECONDARY', 'SECONDARY')
           GROUP BY a.app_req_id)  b     -- Alias added here
    WHERE  b.cnt = 5
    ;You don't really need either alias. In fact, you don't need the sub-query: the query below is equivalent to the one above:
    SELECT    app_req_id
    FROM      app_req
    WHERE     class_symbol     IN ('MBA', 'BTECH', 'BBA', 'SENIOR SECONDARY', 'SECONDARY')
    GROUP BY  app_req_id
    HAVING    COUNT (*)           -- or maybe COUNT (DISTINCT class_symbol)
                     = 5
    ;If the combination (app_req_id, class_symbol) is not unique, then use "COUNT (DISTINT class_symbol)" instead of "COUNT (*)".
    There is only 1 table i am reffering to and need to get the ID where values matches in other column. Other column can have the values as that of MBA,BTECH,BBA,SENIOR SECONDARY and SECONDARY.
    I don't want to use query as -
    Select APP_REQ_ID FROM app_req where class_symbol in ('MBA', 'BTECH', 'BBA', 'SENIOR SECONDARY', 'SECONDARY')
    As this will be with either of the match found. I want where all of the match found.That's what the condition "WHERE b.cnt = 5" in the main query is for.
    >
    Kindly help.If the query above is not doing what you want, then post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data. Point out where the query above is getting the wrong results, and explain, with spoecific examples, how to get the right results in those places.

  • CAN WE HAVE IF CONDITION IN QUERY GENERATOR

    Hi friends,
    am, trying to make use of if condition to obtain a set of values in query generator.  Its possible to retrieve the required result set using query analyser but not in query generator.  am trying to execute the following query
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 1 and owor.itemcode = '100-100')
    begin
                    select itt1.u_reactor1 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 2 and owor.itemcode = '100-100')
    begin
         select itt1.u_reac_23 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 3 and owor.itemcode = '100-100')
    begin
         select itt1.u_reactor4 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    if it is not possible to write such query in query generator  can someone help me with a workaround solution.
    Thank u
    Vaitheeswaran

    Hi,
    I dont think Nested IF Statements are allowed in PLD. The reason that u get the result in Query analyser and not in Query Generator is that SAP supports Transact SQL and many SQL Server 2000 functions are not supported.
    However there is a work around in Print Layout Designer for using IF condition by having Linked Objects. Kindly see some tutorials regarding Linked fields available on SDN site and think of some other way of implementing this nested IF query.
    Regards
    Rizwan Hafeez
    Team Lead
    SAP Addon Development Section
    Abacus Consulting - Pakistan

  • Checkbox Value in where condition of query

    Hi,
    I have a check box which shows values based on the LOV's . If i check on the checkbox the values that are selected on the check box must be used in the where condition to update the table.
    Please suggest me how to take the check box values.
    Am using the below methos to update but its not happening
    Declare
    old_cohort_name varchar2(500);           
    new_cohort_name varchar2(500);
    l_cohort_id apex_application_global.vc_arr2;
    begin
    l_cohort_id := apex_util.string_to_table(:P64_CASCADE_COHORT_NAMES);
    select cohort_name into old_cohort_name from study_cohort
    where cohort_id = :p64_cohort_id;
    select :P64_COHORT_NAME into new_cohort_name from dual;
    if old_cohort_name <> new_cohort_name then
    update study_cohort
    set      
    cohort_name = new_cohort_name
    where cohort_id = :p64_cohort_id and
    cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked
    End if;
    End;
    Please suggest me how to modify the code
    Tx
    Sudhri

    Hi Sudhri,
    where cohort_id = :p64_cohort_id and
    cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked If this is the code you are actually using, then the condition would only be met if l_cohort_id = :p64_cohort_id because you are using an AND condition over the same column in the where clause, so it will only return rows when both values are the same. Then, I think that it seems not to be working for you because :p64_cohort_id and l_cohort_id have different values, and no row is getting updated then. If the values you are selecting in your checkboxes are several ids of rows to update, besides the one with id :p64_cohort_id, then maybe the condition you need is something like this:
    WHERE cohort_id = :p64_cohort_id OR instr(l_cohort_id, cohort_id) != 0;Hope that helps.
    Regards,
    Sergio

  • How to refer a column value of a single row in conditional column display?

    Hello,
    does anybody have an idea, how i can refer a column value of a single row in conditional display of a column?
    So my idea is, that a report has a column, which value is only displayed, when another column value of this row has a specific value.
    I want to solve this problem with condition type: PL/SQL Function Body returning a boolean.
    But I do not know how to refer the column value of each single row!
    Thank you,
    Tim

    Here's a solution that, to me, seems easier to implement but, that's, of course, in the eye of the implementer.
    Rather than using APEX to generate a link column for you, actually create the link as part of your SQL.
    select '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>' CONTACT_LINK, ...
    etc.
    Test this out. You'll see that it works just like making a column a link using the column attributes.
    Next, we'll change the SQL to use a DECODE statement to either display the link or nothing depending on what your criteria is. For example, let's assume you only want a link for active contacts.
    select Decode( CONTACT_STATUS, 'A', '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>', NULL ) CONTACT_LINK, ...
    etc.
    This will not display the link in any rows in which the CONTACT_STATUS is not active, i.e. "A"
    -Joe

  • How to use many conditions in query

    Hi all,
    i have a situation,must prepare a report to find availability of it devices.they are given the specific ip of devices.
    my query
    SELECT 
     Resultdate, [SERVICE]  ,[SERVICE TYPE] ,[IP]
    , DailyAvailability
      FROM [Orion].[dbo].[DepartmentNodesNew] t1
    left join (   select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100  as DailyAvailability,
      count(*) as Node,   c2.ResultDate  ,[Departament]  ,[IPAdress]
       from  [Orion].[dbo].[OrionEventsNodeDownTime] as c2 group by  [Departament] ,[IPAdress] , c2.ResultDate) t2
       on t1.IP=t2.IPAdress 
       where t2.DailyAvailability is not null and t1.SERVICE='SAP CRM' and t2.ResultDate='2014-12-10'
        order by ResultDate
    now how can i calculate the daily availability of sap crm which have 2 servers and they are in cluster,when one is down service is ok.when both of them are down service is off. how can i calculate by writing conditions.
     case when  ([SERVICE]='SAP CRM' AND [SERVICE TYPE]= 'DB Server' and [DownTimeMin] =0) then DBAvailability 100
      else  then DBAvailability select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100 ???

    SELECT Resultdate
    ,[SERVICE]
    ,[SERVICE TYPE]
    ,[IP]
    ,DailyAvailability
    INTO #TempTable
    FROM [Orion].[dbo].[DepartmentNodesNew] t1
    LEFT JOIN (
    SELECT round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100 AS DailyAvailability
    ,count(*) AS Node
    ,c2.ResultDate
    ,[Departament]
    ,[IPAdress]
    FROM [Orion].[dbo].[OrionEventsNodeDownTime] AS c2
    GROUP BY [Departament]
    ,[IPAdress]
    ,c2.ResultDate
    ) t2 ON t1.IP = t2.IPAdress
    WHERE t2.DailyAvailability IS NOT NULL
    AND t1.SERVICE = 'SAP CRM'
    AND t2.ResultDate = '2014-12-10'
    ORDER BY ResultDate
    SELECT Resultdate
    ,[SERVICE]
    ,[SERVICE TYPE]
    ,[IP]
    ,DailyAvailability
    ,CASE
    WHEN (
    [SERVICE] = 'SAP CRM'
    AND [SERVICE TYPE] = 'DB Server'
    AND [DownTimeMin] = 0
    THEN 100
    ELSE round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100
    END AS 'DBAvailability'
    FROM #TempTable
    -Vaibhav Chaudhari

  • Sorting by summary column, query based on previous query.

    Using 10g reports.
    I've got a report with one query currently thats broken down itno a couple groups. I'm trying to change the order they are displyed by based on a summary count of each group. I'm also trying to do another query for the report based on the results of the first one and display that with the information from the first.
    The report currently:
    Chain name
    ABC Stores
        Month
        JUN
         Store Name                   Store ID                bad sales
          Store1                         storeid1                   5
          Store2                         storeid2                   3
          Store3                         storeid3                   1
                                                         month total: 9
    JUL
          Store1                         storeid1                   6
          Store2                         storeid2                   5
          Store3                         storeid3                   2
                                                        month total:13
                                                        Chain total  22
    XYZ Stores
        JUN
          Store1                      storedid1                     20
          Store2                      storedid2                     15
                                                         month total  35
       JUL
          Store1                      storedid1                      11
          Store2                      storedid2                       7
                                                        month total     18
                                                         Chain total     53What I want to do is sort the order the store chains appear in based on the CHain total of bad sales. This is a summary done by the report and not in the sql query at the moment. I would also like to create a second query where it takes the store id and month from the first query and uses it to look up the total sales each store did so I can determine what percentage of the total sales the bad sales were. I would like to add this column plus a calculated percentage column to the right of the current columns but still have them grouped as they are. Is this possible to do or will i need to change my original query?
    Not very familiar with reports and I haven't been able to find anything to indicate how this should/could be done yet. Any help is appreciated.

    hi,
    there is no break order property for summary columns .
    so use the group by and take the sorting order for whole group
    example:
    SELECT DEPTNO, JOB, ENAME, SAL FROM EMP
    ORDER BY SAL
    You then create two groups, G_DEPT and G_JOB. G_DEPT contains
    the DEPTNO column and G_JOB contains the JOB column. If you
    specify a Break Order of Descending for the DEPTNO column and
    Ascending for the JOB column, your output would appear similar
    to that below (assuming you use a Tabular style):
    Deptno Job Ename Sal
    30 CLERK JAMES 950.00
    MANAGER BLAKE 2850.00
    SALESMAN WARD 1250.00
    MARTIN 1250.00
    TURNER 1500.00
    ALLEN 1600.00
    20 ANALYST SCOTT 3000.00
    FORD 3000.00
    CLERK SMITH 800.00
    ADAMS 1100.00
    MANAGER JONES 2975.00
    10 CLERK MILLER 1300.00
    MANAGER CLARK 2450.00
    PRESIDENT KING 5000.00

Maybe you are looking for

  • How to update the inventory after committing order..?

    How to update the Inventory stock level of a commerce item after committing the order.. in ATG 10.0.1..? Thanks in Advance, Vishnu & Nithin Kayithi

  • Firefox 30.0 and 31.0 crashes when trying to print a web page

    Whenever I - or any user in our work environment - try to print a webpage from Firefox, the application crashes. We are all running OS X 10.9.x AdapterDeviceID: 0x fe9 AdapterVendorID: 0x10de Add-ons: %7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D:30.0 B

  • Syntax Error with EXPORT statement in ECC 6

    Hi All, I have one issue with EXPORT statement syntax. I have declared data like below: DATA: BEGIN OF mem_id,           mandt LIKE sy-mandt,           uname LIKE sy-uname,           modno LIKE sy-modno,         END OF mem_id. export the memory id   

  • Yoga 13 Wireless network authentica​tion problem

    I recently bought Yoga 13 and it is a wonderful machine, but since I upgraded to Windows 8.1, I can't connect to my university Wi-Fi. Recommended authentication method for the university's Wi-Fi is WPA-enterprise/TKIP and it's using personal certific

  • Officejet Pro 8600 Plus paper tray will not go all the way in so cannot print

    Have loved this printer for almost two years but suddenly the drawer which holds the paper will not go all the way in so cannot print.  Took it to a so-called tech at Office Depot who said that because you cannot open/remove the tray, there is no way