Question of instruction box to Null condition

Hi friends,

I have an analysis with the so-called following columns:

Effective_date and the column header_id

The results of this analysis will be as for each entry into force there will be the id of header and some of the entry into force will not have id of header and will be null (i.e.) even as below

Courses above, you can see 12/31/2008 id header and the remaining dates have header_id null.

Suppose if I select a date at the prompt, through so-called variables presentation: June 18, 2015 it is today, then analysis for results of the 1-1-2006(which is the default starting year date) dates until June 18, 2015 (this is the year that im selecting the guest) and bottom of filter - what

Ahmed Scenario2.PNG

But my problem is that I have a column header id, and the outcome as to appear in what concerns the dates between (01/01/2006 to 31/05/2015), it must show the id of the header only with null values and not the id header that is not null values and for the remaining dates from (1 June 2015 [01/06/2015] June 18, 2015 [18-06-2015]) it must show the header of all id values (which has both null values, so don't not null values)

So for the condition above, that I replaced the filter underneath like that does not work, because it results in no results.


I wrote something for the id header as filter below in the sql expression

Ahmed Scenario3.png

SQL expression: case when 'Fact_gl_jv '. "" Jvl_effective_date "< = Date ' 2006-01-01' and 'Fact_gl_jv '. "" "Jvl_effective_date" > = TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (Date ' @{T_DATE} {2015-06-18} ""), Date ' @{T_DATE} {2015-06-18}') THEN null ELSE 'Dim4_gl_jvh'. '. Jvh_accrual_rev_je_header_id' END


Im not sure, im lacking in my State. Kindly guide me with this question friends.


Thanks in advance.


Kind regards

Saro

I spent some time on your issue, and we could do this in the following way...

Filter the first criterion

"Fact_gl_jv". "" Jvl_effective_date " between Date ' 2006-01-01' and TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (Date ' @{T_DATE} {2015-06-15}" "), Date ' @{T_DATE} {2015-06-15}" ")

And HeaderID is null

Hope that you will be aware of similar demand combine.

Add another criterion, copy the same criteria you have first, except the filter must be

"Fact_gl_jv". ' "Jvl_effective_date" between TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (Date ' @{T_DATE} {2015-06-15}') + 1, Date ' @{T_DATE} {2015-06-15} "") and the Date ' @{T_DATE} {2015-06-15}'

Not need a HeaderID filter in this report.

I tested it and works very well.

Thank you

AJ

Tags: Business Intelligence

Similar Questions

  • several instructions box in where clause

    Hello

    I'm trying to create report filters using substitution variables in a case statement in a where clause clause. I have several instructions box running on the same column. I don't really know how to write it. Here's what I have so far but I know I'm going in the wrong direction.

    where

    i.compute_zone =

    case

    When: P14_zone is NOT NULL

    then: P14_zone

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_2 is NOT NULL

    then: P14_zone_2

    other: P14_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_3 is NOT NULL

    then: P14_zone_3

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_4 is NOT NULL

    then: P14_zone_4

    of other i.compute_zone

    end

    any suggestions?

    Thank you

    MICAH

    Hi, Micah,

    User12611868-Oracle wrote:

    Hello

    I'm trying to create report filters using substitution variables in a case statement in a where clause clause. I have several instructions box running on the same column. I don't really know how to write it. Here's what I have so far but I know I'm going in the wrong direction.

    where

    i.compute_zone =

    case

    When: P14_zone is NOT NULL

    then: P14_zone

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_2 is NOT NULL

    then: P14_zone_2

    other: P14_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_3 is NOT NULL

    then: P14_zone_3

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_4 is NOT NULL

    then: P14_zone_4

    of other i.compute_zone

    end

    any suggestions?

    Thank you

    MICAH

    How get the desired results of your data depends on the desired results and your data.  What do you do?  (I can't tell just by looking at the aat code that do not do).  After CREATE TABLE and INSERT statements for some sample data and a couple of sets of parameters (variables such as p14_zone) and the exact results that your choices in each set of parameters, given the same sample data.

    Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

    CASE expressions are generally not useful in a WHERE clause.  CASE expressions are a convenient way to IF-THEN-ELSE logic of the places where you can't do anything other than (the SELECT clause), but WHERE the clauses allow IF-THEN-ELSE logic in any case

    Maybe you want something like

    WHERE MERGE (: p14_zone,: p14_zone_2,: p14_zone_3,: p14_zone_4) IS NULL

    OR IN i.compute_zone (: p14_zone,: p14_zone_2,: p14_zone_3,: p14_zone_4)

    It returns TRUE if all 4 parameters are set to NULL.  If 1 or more of them are not NULL, then it will return TRUE if i.compute_zone is equal to one of them.

  • Difference between the expression box and instruction box?

    Hello Experts,

    What is exact diiference between expression box and instruction box

    Except the end and end case?

    Thanks in advance.

    SShubhangi

    A Case statement is used to assign or provide a unique value.

    A Case statement is used as an ELSIF ELSE END IF statement to allow multiple statements to be executed for each condition.

    for example

    Expression box:

    v: = case when sysdate > end target_date then 1 0 otherwise;

    or

    Select case when sysdate > end target_date then 1 0 otherwise like v

    ...

    Case statement:

    case

    When sysdate > target_date then

    v: = 1;

    .. all other instructions...

    on the other

    v: = 0;

    .. all other instructions...

    end case;

  • [8i] problem with query involving an instruction box

    First of all, I work in 8i. I create sample data, etc., I would like to ask if there is a general answer to my question. My query is very complex and to come up with a sample of cases will not be a futile effort, but I will if it ends up being necessary.

    I had a query that worked very well... I got all the results that I expected.

    The query looked something like this:
    SELECT     d.*
    ,     NVL(date_1, date_2)     AS date_filter
    FROM     complex in-line view d
    WHERE     NVL(date_1,date_2)     <= SYSDATE + 10
    ORDER BY     d.col_1
    ,          date_filter
    ,          d.col_2
    ,          d.col_3
    One of the columns of a ' is a sequence number, and there may be multiple lines (if any) associated with a particular sequence number. I call these my result 'groups '.

    I then added a case statement such as:
    SELECT     CASE
              WHEN     d.col_4     IS NOT NULL
              AND     d.col_5     != d.col_6
              AND     d.col_5     NOT IN     ( 
                             another complex query, which is actually the same as an in-line view used in 'd'
                             )
              THEN     '*'
              WHEN     d.col_4     IS NOT NULL
              AND     d.col_5     != d.col6
              THEN     '-'
         END               AS flag
    ,     d.*
    ,     NVL(date_1, date_2)     AS date_filter
    FROM     complex in-line view d
    WHERE     NVL(date_1,date_2)     <= SYSDATE + 10
    ORDER BY     d.col_1
    ,          date_filter
    ,          d.col_2
    ,          d.col_3
    (Note: I also tried using NOT EXISTS instead of NOT IN, with the same results)

    When I ran the new query with the case statement, suddenly d.col_5 do not have the same values. I still have the same number of rows returned, and the same number of lines by "group", but in all the ranks where the case statement returns an asterisk, d.col_5 lacked its value. In addition, a few lines with an asterisk should not have got one, because d.col_5 has been equal to d.col_6 (before the value of d.col_5 was missing its value).

    If I remove the case statement and just run the original query, all values of d.col_5 are back. I don't know why a case statement would affect any other provision of the request...

    Anyone?

    Thanks in advance

    Published by: user11033437 on August 20, 2010 14:15

    Hello

    It's weird!

    No, I've not seen this before.

    Your main query is easier that you posted it? There were bugs in older versions on the use of combinations of functions anlaytic together, and all versions are likely to get confused if you use analytical functions in a CONNECT BY query. But you do it all in the main query you posted.

    I noticed a number of things that could be linked.

    d.col5 NOT IN (SELECT col_x FROM ...)
    

    never returns TRUE if the subquery col_x values are set to NULL. Ensure that the subquery is the condition "col_x IS NOT NULL".

    If the IN subquery in the case statement is exactly the same as a subquery used in d, then consider making a view. (A regular freestanding "CREATE or REPLACE the VIEW" view, not a view online.)

    I don't see how or one of these things would cause the behavior you reported, but you should do them anyway (at least the "col_x IS NOT NULL" condition) and see if the problem persists.

    If you leave the CASE expression, but merely the condition in comment

    --          AND     d.col_5     NOT IN     (
    --                         another complex query, which is actually the same as an in-line view used in 'd'
    --                         )
    

    the problem goes away? (I bet it does; I'm just grasp at straws here.)

    Published by: Frank Kulash, August 20, 2010 17:12

    I wrote the message above before seeing your second message.
    It is even stranger that just change 'NOT IN d.col5' to 'NOT IN d.col6' seems to fix the problem.

  • Distinct count in the instruction box

    -------------------------------------------------------------------------------------------------
    SELECT A.P_ID,
    B.P_NAME,
    C.P_DESC,

    SUM (CASE
    WHEN A.DATE BETWEEN TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE),-4) + 1) AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)),-1)
    AND A.M_ID IS NOT NULL
    THEN 1
    0 OTHERWISE
    END) AS COUNT,
    SUM (CASE
    WHEN A.DATE BETWEEN TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE),-4) + 1) AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)),-1)
    AND A.M_ID IS NOT NULL
    THEN COUNT (DISTINCT A.M_ID)
    0 OTHERWISE
    END) AS UNIQUE_COUNT, / * is not possible * /.
    SUM (CASE
    WHEN A.DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)), - 1).
    THEN A.AMT_1
    0 OTHERWISE
    END) AS TOTAL_AMT_1,
    SUM (CASE
    WHEN A.DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)), - 1).
    THEN A.AMT_2
    0 OTHERWISE
    END) AS TOTAL_AMT_2

    FROM TABLE_A A,.
    TABLE_B B,.
    C TABLE_C


    WHERE A.P_ID = B.P_ID
    AND B.PT_ID = C.PT_ID
    A.P_ID GROUP,
    B.P_NAME,
    C.P_DESC

    ----------------------------------------------------------------------------------------------------------

    Hello

    It is a simplified version of my request.
    I'm doing 4 things here,
    1. the County A.M_ID
    2 County has separate .M_ID, is where I have a problem.
    3 and 4. It is just the sum of 2 diff columns.

    Note that the dates for the County and the amt are different and I can't hard-code the.
    Can someone help me step of distinct count?
    This query runs also a bit slow.
    So all suggestions, comments are welcome.
    Note: TABLE_A REB 700 million, TABLE_B 4 million and TABLE_c is located only 500 RECS
    Thank you!

    Advantage of the fact that aggregate functions more ignore nulls, you could do something like:

    SELECT a.p_id, b.p_name, c.p_desc,
           COUNT(CASE WHEN a.date BETWEEN TRUNC(ADD_MONTHS(LAST_DAY(sysdate),-4) + 1) AND
                                          ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) AND
                           a.m_id IS NOT NULL THEN m_id END) AS countall,
           COUNT(DISTINCT CASE WHEN a.date BETWEEN TRUNC(ADD_MONTHS(LAST_DAY(sysdate),-4) + 1) AND
                                        ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) AND
                         a.m_id IS NOT NULL THEN a.m_id END) AS unique_count, /* entirely possible */
           SUM(CASE WHEN a.date BETWEEN TRUNC(sysdate,'YEAR') AND
                                        ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) THEN a.amt_1
                    ELSE 0 END) AS total_amt_1,
           SUM(CASE WHEN A.DATE BETWEEN TRUNC(sysdate,'YEAR') AND
                                        ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) THEN A.AMT_2
                    ELSE 0 END) AS TOTAL_AMT_2
    FROM table_a a, table_b b, table_c c
    WHERE a.p_id = b.p_id and
          b.pt_id = c.pt_id
    GROUP BY a.p_id, b.p_name, c.p_desc
    

    The two statements inside the COUNTY box return a.m_id or NULL. A simplified test case is:

    SQL> WITH t as (
      2     SELECT 1 m_id, 9 dt FROM dual UNION ALL
      3     SELECT 1 m_id, 6 dt FROM dual UNION ALL
      4     SELECT 2 m_id, 9 dt FROM dual UNION ALL
      5     SELECT 2 m_id, 6 dt FROM dual UNION ALL
      6     SELECT 1 m_id, 5 dt FROM dual UNION ALL
      7     SELECT 2 m_id, 5 dt FROM dual UNION ALL
      8     SELECT null m_id, 9 dt FROM dual)
      9  SELECT count(CASE WHEN dt BETWEEN 6 and 9 THEN m_id end) cid,
     10         count(distinct CASE WHEN dt BETWEEN 6 and 9 THEN m_id end) cdid
     11  FROM t;
    
           CID       CDID
    ---------- ----------
             4          2
    

    I'm not entirely sure that you really need the IS NOT NULL predicate a.m_id in the instructions BOX, but I left it for more security.
    John

  • Problem with variable referencing of presentation (KEY Date) in the instruction box

    Hello

    I'm trying to reference variables of presentation created on a Date column in the instruction box to one of the columns in the query, as shown below:

    -case when '-citation details. "" "Created" between ' @{of} {1999-1-1}' and ' @{until} {2999-1-1} "then"-quote Metrics. " "" end of number of citations.

    I m getting a view displays error message with the following error message:

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 17001] Oracle error code: 1861, message: ORA-01861: literal does not match the format string to the call of the OIC OCIStmtExecute

    SQL issued: SELECT "-quote Types '." Name of level 2 Saw_0', case when '-citation details. "" Created "between" 01/04/2009 ' and ' 15 / 04/2009 ' then '-quote Metrics ' "." number of citations"end saw_1"(unit) - CATALOGUE of quotes"WHERE"-citation details "". "" Date of creation"BETWEEN timestamp ' 2009-04-01 00:00:00 ' timestamp AND ' 2009-04-15 00:00:00 ' ORDER BY saw_0


    When I created the prompt on the date field, I put the following in the command prompt:
    Cast ("-time".) Day)

    When I apply a filter on the query using these variables, it works fine.

    If anyone has faced this kind of question earlier and have a resolution, please help me.

    Thank you
    Kitenge

    Hello.

    Select the double - A NON-VALIDE MONTHS TO_DATE('1999-1-1','mm/dd/yyyy')

    Try this:

    OLD: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {1999-1-1} ", mm/dd/yyyy)
    NEW: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {01/01/1999} ", mm/dd/yyyy)

    and

    OLD: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {2999-1-1} ", mm/dd/yyyy)
    NEW: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {1, 1, 2999} ", mm/dd/yyyy)

    and if not ok after that, after an error in query SQL of NQQuery.log.

    Kind regards

    Goran Ocko

    http://108obiee.blogspot.com/

  • Problem with calculation of measurement using instruction box

    Hello Experts

    I have a measure that calculates the percent of sales by State - "sale by States" / "Total sales" * 100 and the requirement is when the numerator of the measure is < 11 then it should be ' *'. I tried to write a next case statement case when sales by State < 11 THEN ' *' ELSE sales by State END / "Total sales" * 100. I get an error saying incompatibility of data type of ideas how I can make it work.

    Thank you
    RC

    Published by: user1146711 on July 12, 2012 07:39

    Published by: user1146711 on July 12, 2012 09:17

    Hi RC,.

    I used to have the same than the one that I solved it using the following statement hope, that it will aid.

    BOX WHEN ((ARRAY. NUMERATORCOLUMN< 11))="" then="" '*'="" else="" concat(cast(round((((numerator="" column)/(denominator="" column))*100),1)="" as="" char(50)),'%')="">

    Here the results of instruction box in the two values is * Alternatively, value (which is stored as varchar instead of the number data type).
    Have, so the results are varchar. you get no data type mismatch error.

    That, by your statement the case... A case get varchar and another survey number which is the offset. (Logic)

    I have concatenated with the '%' sign to show results under 15%, 16% and stores the same results (Varchar).

    I hope that this solves your problem. Please, attribute points. :) :)

    Let me know, if you still find problems.

  • question about this instruction box... Never seen written in this way

    I case this statement written by a developer, and I try to understand what he was trying to accomplish with the write this way
    CASE t_CELL
                    WHEN 'XML' THEN
                        'Mods'
                    ELSE
                        CASE WHEN t_CELL IS NOT NULL THEN
                            t_Cell
                        ELSE
                            CELL
                        END
                    END
                = CELL OR CASE t_CELL
                    WHEN 'XML' THEN
                        'Amps'
                    ELSE
                        CASE WHEN t_CELL IS NOT NULL THEN
                            t_Cell
                        ELSE
                            CELL
                        END
                    END = CELL);
    What is throwing me off the coast is the = CELL which was included... Please note, this is just one example of code

    Well, simplified, it looks like:

    CASE WHEN t_CELL = 'XML' THEN 'Mods'
         ELSE NVL(t_CELL, CELL)
         END
    = CELL
    OR
    CASE WHEN t_CELL = 'XML' THEN 'Amps'
         ELSE NVL(t_CELL, CELL)
         END
    = CELL
    

    Shows that there are two distinct conditions to test, so I guess this is part of a WHERE clause of a query or an another CASE statement, or an assignment to a variable of the BOOLEAN in PL/SQL?

    It is often more logical (more readable) to put the MATTER on the right side of the State, for example

    WHERE CELL = CASE WHEN t_CELL = 'XML' THEN 'Mods'
                      ELSE NVL(t_CELL, CELL)
                 END
    OR    CELL = CASE WHEN t_CELL = 'XML' THEN 'Amps'
                 ELSE NVL(t_CELL, CELL)
                 END
    
  • need help in the instruction box

    Dear experts,

    IM using oracle 11g

    CREATE TABLE PAYLOG

    (

    ID VARCHAR2 (20).

    DESCRIPTION VARCHAR2 (20)

    );

    INSERT INTO PAYLOG VALUES ("1, ' NOT CAPTURED");

    INSERT INTO PAYLOG VALUES(2,'CAPTURED');

    INSERT INTO PAYLOG VALUES(3,'APPROVED');

    Here is the example output query example, I needed to know.

    SELECT THE CHECK BOX

    WHEN DESCRIPTION = 'CAPTURED' and 'APPROVED' - THEN when the captured data are currently it should display approved

    Where description = 'CAPTURED or APPROVED' then 'approved' - when the data "CAPTURED or APPROVED" is present then display approved

    When the description not in ("CAPTURED", "NO CAPTURE", "APPROVE") then 'rejected' - not in all these 3 data and then display rejected

    ) alias_name

    END

    OF PAYLOG;

    Now, I want to apply the same logic to query below

    with the temp as

    (

    Select

    (CASE

    DESCRIPTION = "NOT CAPTURED" THEN "rejected by the question.

    DESCRIPTION = "CAPTURED or APPROVED" then "APPROVED."

    WHEN NOT IN DESCRIPTION ("CAPTURED", "CAPTURED", "APPROVE") THEN 'OTHERS '.

    )

    snapshot_detail,

    Count (*) NTC, sum (payment_amnt) total

    of PAYLOG

    )

    Select snapshot_detail, sum (NTC) TOTAL_COUNT, sum (total) TOTAL_VALUE, round ((sum (NTC) / sum (NTC) over()) * 100.2) PERCENTAGE

    temp

    Group total, snapshot_detail, cnt

    Union of all the

    Select 'Total', sum (cnt), sum (total) TOTAL_VALUE, round ((sum (NTC) / sum (cnt)) * 100.2)

    temp

    Please help experts.

    What of this

    with temp as
    (
    select snapshot_detail, sum(cnt) cnt , sum(total) total
    from (
        select
          CASE
            WHEN DESCRIPTION        = 'NOT CAPTURED'                      THEN 'Rejected by Issue'
            when DESCRIPTION        = 'CAPTURED' or DESCRIPTION='APPROVED'            THEN 'APPROVED'  ----------------------------i want only one condition to be satisfied here
            WHEN DESCRIPTION NOT IN ('NOT CAPTURED','CAPTURED','APPROVED')THEN 'OTHERS'
          end snapshot_detail,
          count(*) cnt,
          sum(payment_amnt) total
        from paylog
        group by description )
    group by snapshot_detail
    )
    select snapshot_detail, sum(cnt) TOTAL_COUNT,sum(total) TOTAL_VALUE ,round((sum(cnt) / sum(cnt) over()) *100,2) PERCENTAGE
      from temp
     group by snapshot_detail ,total,cnt
    union all
    select 'Total', sum(cnt), sum(total) TOTAL_VALUE,round((sum(cnt) / sum(cnt)) *100,2)
    from temp;
    
  • Resovle 00904 with instruction box

    Hello

    Maybe a stupid question, but I got the following situation. I have an update query, and I tried to solve a message 00904 with a case statement. Would this be possible?

    I use a case because in a version a specific field cannot exist.

    Query

    UPDATE xp table

    SET of xp. ATTRIBUTE =

    CASE

    ((select version from_parameters) = 1') THEN "//FIELD IS NOT EXISTING

    WHEN ((version select à partir de paramètres) = '2') THEN

    SELECT THE EXISTING FIELD

    ELSE "

    END

    However the request always fails with 00904 even when version = "1". It could be possible that I ask or is there just no solution for this?

    Best regards

    Richard

    Hello

    user12235295 wrote:

    Hi Frank,.

    Thnak you for your comments, will keep in mind the next time.

    My question is more general. For example, if you have an application that communicates with Oracle Financials R11 or R12 it can be diffence in the fields in the tables. R12 was generally more fields.

    My question is if you use a case statement, do all the fields must be present in order to compile the query, even if these fields are not used in this specific version.

    It seems that, even when you use a case statement, every field must be present must be present.

    Exactly!  The SQL statements are compiled first; then, if there is no error in compilation, they are executed.  Verify that all the columns exist is part of the compilation, so there is nothing you can do in the exercise of the against (an expression BOX, for example) which can avoid the error: the error prevents the CASE expression (and the rest of the statement) still running.

    If a column exists in some versions of your software, you need dynamic SQL statements.  There are so many problems with dynamic SQL that most people find that this isn't punishment; they write different different code for different versions.

    PL/SQL has a feature of conditional compilation; in other words, you can put the precompilation directives in your code that say some sections are made only in certain circumstances (for example, you have a certain version) and ignored otherwise.  SQL and SQL * more no feature of this

  • Error with an instruction box in a region of report

    Hello

    I have a report, when I use the case in the source of the region, I have an error message.

    There are three fields in the report: from, to, resident

    Before the deal, it works very well and as follows:

    Select count (t1.id) pcount, c5, c6, seqnum

    from t1, t2 tablename tablename1 2

    where t1.ID = t2.pid

    and (t1.resident =: P251_RESIDENT)

    or t1... resident2 =: P251_RESIDENT)

    and t1.pdate between to_date(:P251_FROM,'mm/dd/yyyy')

    and to_date(:P251_TO,'mm/dd/yyyy')

    Group of c5, c6, seqnum

    After having added the condition of 'case', I

    1 error has occurred

    • Query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the generic "columns" box below the source of the region without analysis. ORA-00933: SQL not correctly completed command.

    Select count (t1.id) pcount, c5, c6, seqnum

    from t1, t2 tablename tablename1 2

    where t1.ID = t2.pid

    case

    When: P251_RESIDENT is not null then

    and (t1.resident =: P251_RESIDENT)

    or t1.resident2 =: P251_RESIDENT)

    end

    case

    When: P251_FROM is not null and: P251_TO is not null then

    and t1.pdate between to_date(:P251_FROM,'mm/dd/yyyy')

    and to_date(:P251_TO,'mm/dd/yyyy')

    end

    Group of c5, c6, seqnum

    can anyone help?

    Thank you

    Jen

    If you want SQL to return all the lines when the value of the element is zero, you test as part of the WHERE clause directly and adjust your Boolean logic accordingly.

    for example

    WHERE T1.ID=T2.PID
      AND
        ( :P251_RESIDENT IS NULL OR
              ( T1.RESIDENT = :P251_RESIDENT or T1.RESIDENT2 = :P251_RESIDENT )
         )
      and ( :P251_FROM is null OR
                to_date( :P251_FROM, 'mm/dd/yyyy' ) < T1.pdate
            )
      and ( :P251_TO is null
               or T1.pdate < to_date( :P251_TO, 'mm/dd/yyyy' )
       )
    

    Your SQL required so much P251_FROM than P251_TO in order to work.

    It will work with one or the other or both.

    MK

  • How to use the instruction box in where clause

    Hi all


    I need to use cases where clause guide me please how I can do it.


    AND WHEN BOX: KAPCO = "KAPCO" THEN cla. CLASS_NAME LIKE '% KAPCO % '.
    WHEN: KAPCO = "NON_KAPCO" THEN SUPERIOR (cla. CLASS_NAME) NOT LIKE '% KAPCO % '.
    WHEN: KAPCO = 'ALL' GOLD: KAPCO IS NULL SO SUPERIOR (cla. CLASS_NAME) LIKE '% '.
    END



    Concerning

    Published by: user10941925 on March 4, 2012 22:31

    Hello

    CASE expressions return a single value, for example a VARCHAR2. They do refer to code fragments.

    You usually don't need (or want) an expression BOX in a WHERE clause, or any other condition. I think that you were trying to do the equivalent of:

    AND     (     (:KAPCO = 'KAPCO'          AND cla.CLASS_NAME       LIKE '%KAPCO%')     -- Don't you want UPPER on this line?
         OR     (:KAPCO = 'NON_KAPCO'           AND UPPER(cla.CLASS_NAME) NOT LIKE '%KAPCO%')
         OR     (NVL (:KAPCO, 'ALL') = 'ALL'       AND cla.CLASS_NAME IS NOT NULL)
         )
    

    If you would care to post some sample data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.

  • Iphone6 is disabled. Forgotten the answers to security questions.  Rescue box email address is no longer in support...

    Hello

    My iphone6 is disabled.

    Due to the number of years that have elapsed since registration, I forgot the answers to security questions.  Is devoted to the issue, my box of rescue email address is no longer in use... help... Thank you.

    You must ask security team account Apple to reset your security questions. To contact them, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.

    (140609)

  • I created a form with checkboxes.  A question has two boxes for a 'yes' another being a 'no '.  I just want to be able to select a single box, but currently, I choose both

    I created a form with checkboxes, I have currently two checkboxes in a question that I wish I could only check a box and make it mandatory that should be checked only one box.  Currently, I am able to select the two check boxes.

    Give them the same field name, but export values.

  • where can I use statement box put Null or not primary key or null in the result?

    create the table test_target

    (

    letter_grade varchar2 (2) null,

    grade_point number (3,2) not null,

    max_grade number (3).

    min_grade number 4

    );

    create the table test_source

    (

    letter_grade VARCHAR2 (3),

    grade_point number (3,2).

    max_grade number (3,2).

    min_grade number (3).

    created_by date,

    Modified_By date

    );

    with the CBC as

    (

    Select src.table_name src_table_name, src.column_name src_col_name, src.data_type src_data_type, src.data_length src_data_len, src.data_precision src_data_precision, src.data_scale src_data_scale, src.nullable src_nullable

    user_tab_columns CBC

    where table_name = 'TEST_SOURCE '.

    ),

    As TGT

    (

    Select tgt.table_name tgt_table_name, tgt.column_name tgt_col_name, tgt.data_type tgt_data_type, tgt.data_length tgt_data_len, tgt.data_precision tgt_data_precision, tgt.data_scale tgt_data_scale, tgt.nullable tgt_nullable

    of tgt user_tab_columns

    where table_name = 'TEST_TARGET '.

    ),

    col_details as

    (

    Select src.src_table_name, nvl (tgt.tgt_table_name, first_value (tgt_table_name) more (order of nulls last tgt_table_name)) tgt_table_name;

    SRC.src_col_name, src.src_data_type, src.src_data_len, src.src_data_precision, src.src_data_scale, src.src_nullable,

    TGT.tgt_col_name, tgt.tgt_data_type, tgt.tgt_data_len, tgt.tgt_data_precision, tgt.tgt_data_scale, tgt.tgt_nullable

    the CBC

    outer join left tgt

    on)

    SRC.src_col_name = tgt.tgt_col_name

    )

    )

    Select *.

    de)

    Select the case sensitive option

    When tgt_data_type! = src_data_type or tgt_data_len! = src_data_len or tgt_data_precision! = src_data_precision or tgt_data_scale! = src_data_scale or tgt_nullable! = src_nullable

    then 'alter table ' | tgt_table_name | 'Edit ' | tgt_col_name | ' ' || src_data_type | ' (' ||

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    When tgt_col_name is null

    then 'alter table ' | tgt_table_name | 'Add ' | src_col_name | ' ' || src_data_type |

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    end alter_statement

    of col_details

    )

    where alter_statement is not null;

    result:

    ALTER table TEST_TARGET change LETTER_GRADE VARCHAR2 (3) / / if it is null or not null primary key or want to see the result as alter table TEST_TARGET change LETTER_GRADE VARCHAR2 (3) null or not null or primary key

    ALTER table TEST_TARGET change the NUMBER of MAX_GRADE (3, 2)

    ALTER table TEST_TARGET change the MIN_GRADE NUMBER (3, 0)

    ALTER table TEST_TARGET add CREATED_BY

    ALTER table TEST_TARGET add MODIFIED_BY

    Please try:

    drop table test_target purge;

    drop table test_source purge;

    create the table test_target

    (

    letter_grade varchar2 (2) primary key,.

    grade_point number (3,2) not null,

    max_grade number (3) unique.

    min_grade number 4,

    MIN_AGE number 4

    );

    create the table test_source

    (

    letter_grade VARCHAR2 (3),

    grade_point number (3,2).

    max_grade number (3,2).

    min_grade number (3).

    created_by date,

    Modified_By date

    );

    with the CBC as

    (

    Select src.table_name src_table_name, src.column_name src_col_name, src.data_type src_data_type, src.data_length src_data_len, src.data_precision src_data_precision, src.data_scale src_data_scale,

    CBC. Nullable src_nullable, decode (T.Constraint_Type, 'P', 'Primary Key', 'U', 'Unique', ") as src_cons

    user_tab_columns CBC

    left join (select Cc.Column_Name, Uc.Constraint_Type

    of user_cons_columns cc, uc user_constraints

    where Cc.Constraint_Name = Uc.Constraint_Name

    and Cc.Table_Name = Uc.Table_Name) t

    on T.Column_Name = Src.Column_Name

    where table_name = 'TEST_SOURCE '.

    ),

    As TGT

    (

    Select tgt.table_name tgt_table_name, tgt.column_name tgt_col_name, tgt.data_type tgt_data_type, tgt.data_length tgt_data_len,

    TGT.data_precision tgt_data_precision, tgt.data_scale tgt_data_scale, tgt.nullable tgt_nullable,

    Decode (T.Constraint_Type, 'P', 'Primary Key', 'U', 'Unique', ") as tgt_cons

    of tgt user_tab_columns

    left join (select Cc.Column_Name, Uc.Constraint_Type

    of user_cons_columns cc, uc user_constraints

    where Cc.Constraint_Name = Uc.Constraint_Name

    and Cc.Table_Name = Uc.Table_Name) t

    on T.Column_Name = TGT. Column_Name

    where table_name = 'TEST_TARGET '.

    ),

    col_details as

    (

    Select src.src_table_name, nvl (tgt.tgt_table_name, first_value (tgt_table_name) more (order of nulls last tgt_table_name)) tgt_table_name;

    SRC.src_col_name, src.src_data_type, src.src_data_len, src.src_data_precision, src.src_data_scale, src.src_nullable, src_cons,

    TGT.tgt_col_name, tgt.tgt_data_type, tgt.tgt_data_len, tgt.tgt_data_precision, tgt.tgt_data_scale, tgt.tgt_nullable, tgt_cons

    the CBC

    outer join full tgt

    on)

    SRC.src_col_name = tgt.tgt_col_name

    )

    )

    Select *.

    de)

    Select the case sensitive option

    When tgt_data_type! = src_data_type or tgt_data_len! = src_data_len or tgt_data_precision! = src_data_precision or tgt_data_scale! = src_data_scale or tgt_nullable! = src_nullable

    then 'alter table ' | tgt_table_name | 'Edit ' | tgt_col_name | ' ' || src_data_type | ' (' ||

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    ||

    cases where tgt_nullable = 'Y' then 'null '.

    of another end 'not null '.

    || tgt_cons

    When tgt_col_name is null

    then 'alter table ' | tgt_table_name | 'Add ' | src_col_name | ' ' || src_data_type |

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    || tgt_cons

    When src_col_name is null

    then 'alter table' | tgt_table_name: ' drop '. tgt_col_name

    end alter_statement

    of col_details

    )

    where alter_statement is not null;

    priamry key and unique key you choose user_contraints

    Check and change for your condition

    Concerning

    Mr. Mahir Quluzade

Maybe you are looking for