Disqualification - CASE or DECODE statement writing

Test

Edited by: user4362313 may 3, 2013 05:00

Hi Bala,

If I interpreted the statement correctly, then you are wanting fill the digits left of the decimal point to four characters, so 12.345 becomes 0012.345.

The best way to achieve this is by using a processor of Expression (see the online help for details of full syntax). Assuming that the input attribute is called 'col1' then the following expression should lead to the desired result:

substr ('000' | col1, indexof (col1, ".") - 1).

Kind regards
Nick

Tags: Fusion Middleware

Similar Questions

  • Need help in writing the SQL CASE or DECODE statement

    Hi experts,

    I need to write a SQL select order_num, cntry_cde, prod_id and Qty by joining order_num on PROD_ORDER and PROD_ORDER_TXT.

    Here is my sample data

    PROD ORDER_
    order_num Prod_id Qty cntry_cde
    100 US A1 5
    101 US 10 A2
    102 IN A3 4
    103 TO THE A4 9
    104. IN A5 3

    PROD ORDER_TXT_
    cntry_cde Prod_id order_num
    100 US A1
    101 US A2
    102 NZ A3
    103 TO THE A4
    A5 104

    Here's the requirement,

    (1) if the cntry_cde in PROD_ORDER is the same as cntry_cde in PROD_ORDER_TXT then select PROD_ORDER.cntry_cde (orders 100, 101, 103)
    (2) if they are different, choose PROD_ORDER_TXT (order 102, to THE NZ <>) country code
    (3) if they are different and PROD_ORDER_TXT.cntry_cde is null, I can't use it like cntry_cde in my report (order 104). It happenend just because of bad data to the source.
    I can't avoid it. Then just use the cntry_cde of PROD_ORDER

    Expected results
    100 US A1 5
    101 US 10 A2
    102 NZ A3 4 - changed in NZ
    103 TO THE A4 9
    104. IN A5 3 - IN retained as PROD_ORDER_TXT.cntry_cde is null


    instructions for creation and insertion of sample table are lower than

    create the table prod_order
    (number of order_num,
    cntry_cde CHAR (2),
    prod_id VARCHAR2 (6).
    number of quantity)

    create the table prod_order_txt
    (number of order_num,
    cntry_cde CHAR (2),
    prod_id VARCHAR2 (6))

    insert into prod_order values (100, 'WE', 'A1', 5);
    insert into prod_order values (101, 'WE', 'A2', 1);
    insert into prod_order values (102, ' to THE ', 'A3', 4);
    insert into prod_order values (103, ' to THE ', 'A4', 9);
    insert into prod_order values (104, 'IN', 'A5', 3);



    insert into prod_order_txt values (100, 'WE', 'A1');
    insert into prod_order_txt values (101, 'WE', 'A2');
    insert into prod_order_txt values (102, 'NZ', 'A3');
    insert into prod_order_txt values (103, ' to THE ', 'A4');
    insert into prod_order_txt values (104, 'A5', NULL);

    commit;

    Thank you for your help in advance

    Published by: manon March 28, 2012 13:39
  • Problem with Decode statement

    Hello

    I try to do the following in my report:

    If an employee is a family name. (dot) or a name of. (dot), the report does not display a point. An employee name consists of the family name, first name and middle name, which should all be concatenated sets. An attempt to achieve this goal, I have the following statement in my report:

    Decode (e.Surname, '.', (LTRIM (RTRIM ((INITCAP (e.FIRST_NAME))) |))) » '|| INITCAP (e.MIDDLE_NAME))),
    e.FIRST_NAME, '.', (LTRIM (RTRIM ((INITCAP (e.Surname))) |)) » '|| INITCAP (e.MIDDLE_NAME))),
    (LTRIM (RTRIM ((INITCAP (e.SURNAME))) | ',' |)) INITCAP (e.first_name) | » '|| INITCAP (e.MIDDLE_NAME))) as emp_name

    E employee

    Problem: The above statement only works for employees with the name of. (dot). It doesn't for the first names of dot. How to use the decode statement OR is there another way to do it without using the CASE statement?

    It seems my decode statement does not work with 2 different fields (name, first name) tested within the decode statement. Thank you.

    LTRIM and RTRIM the comma too:

    select rtrim(ltrim(rtrim(ltrim(', Somename ,',','),','))) Name
    from dual;
    
    NAME
    --------
    Somename
    
  • No CASE or DECODE

    I have a table with say a column called 'COLOUR' with 500 different values - lets say 3 values are red white and blue. There are 497 other

    I want to insert table with the column of color in another table called 'OTHER '.
    But whenever I hit a blue, I want to insert red instead. All other values remain the same as they are.
    I tried CASE and DECODE, but it leaves me with NULL values for others 497 values. Is there a way to do saying only when I hit the blue, I want it to be red, without hard-code all other values? For example:
    Insert into ANOTHER table
    Select
    COLUMN1,
    COLUMN2,
    COLUMN3,
    COLOR (if color is blue, red insert - then let all the other colors to be what they are)
    COLUMN 5

    It would be useful to show the CASE statement that failed. But I think that you would

    INSERT INTO destinationTable( list_of_columns )
      SELECT list_of_columns,
             (CASE WHEN color = 'BLUE' THEN 'RED' ELSE color END) color
         FROM sourceTable
    

    Justin

  • DECODE statement and the argument limits

    No one knows the number of arguments that the DECODE statement allows you to enter. I currently have 863 and it gives me an error message when I try to run the query.

    Database - ORA-00939 error: too many arguments for the function.

    Thank you
    Chris

    Hello

    You still have too many parameters your decodes, the limit is 250 so you can enter only 124 values and decoded. I would like to nest decodes by doing:

    DECODE (point, "c1", "v1", "c2", "v2", "c3", "v3",..., DECODE (point, 'c4', 'v4', 'c5', 'v5', 'c6', 'v6',..., DECODE (...)))

    Alternatively, you can for example use case

    WHEN BOX point IN ( END)

    Rod West

  • Calculation grouping using decode statement?

    I have 4 sales reps who are numbered 9801, 9802, 9803 VRP, 9804.

    I have 3 support staff that support accounts by virtue of these representatives of REPS 1, 2, 3

    Support rep 1 will support the commercial attaché 9801 & 9802
    Support rep 2 will support the commercial attaché 9802 and 9803
    Support rep 3 will support the commercial attaché 9803 & 9804.

    Initially, I had a report which gave the results for all listed sales reps. The representatives of support and then imported it into excel and delete the records of the sales reps that they do not need.

    I want to create a page filter that will support rep select its name in a drop-down which shows only sales reps they support. So support rep 1 can select their name from the drop down and the report would only show information for the commercial attaché 9801 & 9802.

    I tried to do this with a calculation using the decode statement, but it does not work. It seems only to associate support rep to each sales representative. Is there a way to accomplish the grouping I want?

    DECODE (put into commercial service Rep.Sales,
    9801,'REP ' 1,.
    9802,'REP ' 1,.
    9802, ' REP 2',
    9803, ' REP 2',
    9803, ' REP 3',
    9803, ' REP 4'.
    9804, ' REP 4'.
    "ERROR")

    Hello

    I don't think you can do it easily if you want to use a filter on the page. This is because if a row is returned by the database that has a sales of 9802, then, the line must be on 2 pages.

    You can create a parameter to select the support rep and use this setting to select the records. Therefore, if the parameter is p_support_rep then you have a condition like:

    (: p_support_rep = 'REP1' AND sales_rep IN (9801, 9802)) OR
    (: p_support_rep = "REP2' AND sales_rep IN (9802, 9803)) OR
    (: p_support_rep = "REP2' AND sales_rep IN (9803, 9804))

    If you really need to use a filter on the page, then you will need to use a generator of line to create a line for each support rep and to join your generator line report by using a report similar to the one above. You can search for "Generator line" of this forum, or check out the learndiscoverer blog (http://learndiscoverer.blogspot.com/2008/10/row-generators.html) for more details.

    Rod West

  • Help in to convert CASE to DECODE in 11g sql

    11 GR 2, Windows.

    Can someone help me rewrite under sql CASE statement to DECODE?
    SELECT INVOICE_ID,sum(TOTAL_EXCL_VAT),LEVEL2 as descr,
    sum(case when instr(LEVEL2,'Internet')>0 then SUM_QUANTITY else 0 end) as KB  --- >> Here
    from rator_cdr.INVOICE_DETAIL_LINE 
    WHERE INVOICE_ID ='000000000000000000' and CALLER='0000000000' and LEVEL1='Gesprekskosten' 
    group by LEVEL2,INVOICE_ID;
    Thank you

    Why would you want to replace the much more expressive syntax of CASES with a DECODING?

    If you are really determined

    DECODE( instr( level2, 'Internet' ), 0, 0, sum_quantity )
    

    I would strongly prefer the option CASE, however.

    Justin

  • How to use the case and decode to extract data

    Hello gurus of PL/SQL,.

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64-bit Production version

    I have a table in the following form-
    drop table TT2;
    create table TT2(College, Class,gender,status,fees) as select
    'IITB','MBA','M','P',255600 from dual union all select
    'IITK','MTech','M','P',300000 from dual union all select
    'IITD','MBA','F','P',450000 from dual union all select
    'IITKH','MBA','F','P',350000 from dual union all select
    'IITC','MTech','F','P',420000 from dual union all select
    'IITB','MTech','M','P',185000 from dual union all select
    'IITC','MTech','M','P',235000 from dual union all select
    'IITD','MBA','F','F',175000 from dual union all select
    'IITM','MBA','M','F',257000 from dual union all select     
    'IITKH','MTech','F','P',335000 from dual union all select
    'IITD','MBA','F','P',540335 from dual union all select
    'IITC','MBA','F','F',125089 from dual union all select
    'IITD','MTech','M','P',290756 from dual union all select
    'IITM','MBA','M','P',200000 from dual union all select     
    'IITKH','MBA','F','F',534990 from dual union all select
    'IITD','MBA','F','P',221000 from dual ;
    certain conditions of extraction are as follows-

    MATTER OF STATE
    College of 'IITB' and status = 'P'-'good WestRegion '.
    College of 'IITC' and status = 'P'-'good SouthRegion '.
    College 'IITD' and 'IITK' and status = 'P' and type = 'F' - 'female NothRegion spent.
    College not in 'IITK' and status = 'F' - 'Ex Kanpur Failed'

    Results-
    Region Statnding     Fees
    WestRegion Passed     440460
    SouthRegion Passed     655000
    NothRegion Female Passed     1386335
    Ex Kanpur Failed     1092079
    Used SQL
    I use the following query that only make sure of the case, but it's not how I want to exit, if I try to use the case to breast to decode then how to work on it.
    SELECT (CASE WHEN College in ('IITB') and status='P' then sum(fees) else 0 end) WP,
    (case when College in ('IITC') and status='P' then sum(fees) else 0 end) SP,
    (case when College in ('IITD','IITK') and gender='F' and status='P' then sum(fees) else 0 end) NFP,
    (case when College in ('IITK') and status='F' then sum(fees) else 0 end) ExKF
    FROM 
    TT2
    GROUP BY College, Class,gender,status
    SELECT CASE WHEN College in ('IITB') and status='P'
                        then 'WestRegion Passed'
                when College in ('IITC') and status='P'
                        then 'SouthRegion Passed'
                when College in ('IITD','IITK') and gender='F' and status='P'
                        then 'NothRegion Female Passed'
                when College in ('IITK') and status='F'
                        then 'Ex Kanpur Failed'
                else 'Others' end region_standing,
                sum(fees) fees
    FROM TT2
    GROUP BY  CASE WHEN College in ('IITB') and status='P'
                        then 'WestRegion Passed'
                when College in ('IITC') and status='P'
                        then 'SouthRegion Passed'
                when College in ('IITD','IITK') and gender='F' and status='P'
                        then 'NothRegion Female Passed'
                when College in ('IITK') and status='F'
                        then 'Ex Kanpur Failed'
                else 'Others' end;
    
  • How to use CASE or DECODE into that?

    Hi, I have a query like this
    AND ...smthng
    AND --smtg
    AND age BETWEEN ....
    For the last clause AND the age column, I have the values passed param in the AOC as strings
    0 '-30', 31-60, 61-90, and ' 91 +'. The setting IN of course is VARCHAR2.

    What I want to do in this clause AND
    for example, for age will '' 0-30, the clause AND should be

    AND BETWEEN age (if this interval is 0 '-30' then) AND 30 0 (if it falls between 31-60'), then BETWEEN 31 AND 60... and so on...
    However this BETWEEN will work up to 61-90 of range but for 91 +, there is no upper limit so it should be
    AND age > 91

    Now, I don't know how to achieve both BETWEEN and ' > ' clauses in the same statement AND.

    DECODE will not work and do not know how to use the CASE in this situation that even this cannot solve this problem.

    Don't want to do the last clause AND Dynamics

    Please suggest me how to do this.

    Thank you
    Aashish

    Published by: Sylvie S. on October 21, 2011 18:01

    A third possibility would be to choose a sufficiently high value as a high-end for the Group 91 + and use something like:

    age between to_number(CASE WHEN instr(:param, '+') = 0
                                  THEN substr(:param, 1, instr(:param, '-') -1)
                                  ELSE substr(:param, 1, instr(:param, '+') -1) end) and
                to_number(CASE WHEN instr(:param, '+') = 0
                               THEN substr(:param, instr(:param, '-') +1)
                               ELSE '9999' END)
    

    John

  • Nesting help DECODE statements

    Hello. I'm writing a sql script to generate the data for payments report. I need to integrate specific to the field of ADDRESS VACUUM lines to REMOVE conditions. I'm using Address_Line1, Address_Line2, Address_Line3, most CITY, STATE, ZIP as Address_Line4. If all fields are empty, I need to remove the blank line and back up the other lines.

    Here is my if, THEN, ELSE conditions. There are 9 possible scenarios that I have identified. Can you please help me write this in SQL with the DECODE function?
    IF CITY||STATE||ZIP IS NULL               
    THEN AD1='12115 Rainbow Road', AD2='Hartford Heights, MO 60226'               
    ELSE               
         IF ADDRESS_LINE1 IS NULL          
              IF ADDRESS_LINE2 IS NULL     
                   IF ADDRESS_LINE3 IS NULL
                   THEN USE HOME ADDRESS
                   ELSE vAD1=ADDRESS_LINE3, vAD2=CITY||STATE||ZIP
                   ENDIF
              ELSE     
                   IF ADDRESS_LINE3 IS NULL
                   THEN vAD1=ADDRESS_LINE2, vAD2 = CITY||STATE||ZIP
                   ELSE vAD1=ADDRESS_LINE2, vAD2=ADDRESS_LINE3, vAD3=CITY||STATE||ZIP
                   ENDIF
              ENDIF     
         ELSE          
              IF ADDRESS_LINE2 IS NULL     
                   IF ADDRESS_LINE3 IS NULL
                   THEN vAD1=ADDRESS_LINE1, vAD2=CITY||STATE||ZIP
                   ELSE vAD1=ADDRESS_LINE1, vAD2=ADDRESS_LINE3, vAD3=CITY||STATE||ZIP
                   ENDIF
              ELSE     
                   IF ADDRESS_LINE3 IS NULL
                   THEN vAD1=ADDRESS_LINE1, vAD2=ADDRESS_LINE2, vAD3=CITY||STATE||ZIP
                   ELSE vAD1=ADDRESS_LINE1, vAD2=ADDRESS_LINE2, vAD3=ADDRESS_LINE3, vAD4=CITY||STATE||ZIP
                   ENDIF
              ENDIF     
         ENDIF          
    ENDIF               
    This what I've got so far...
    
    DECLARE
      vADR1
      vADR2
      vADR3
      vADR4
    BEGIN
    SELECT
    DECODE(
    
    END;
    /

    Hello

    Interplay says:
    ...
    Here's the script:

    WITH got_delimited_list AS
    (
    SELECT address_line1 || ' +' ||
    address_line2 || ' +' ||
    address_line3 || ' +' ||
    ...
    

    This is equivalent to

    SELECT  (address_line1 || ' ')    || '+' ||
         (address_line2 || ' ')    || '+' ||
         (address_line3 || ' ')    || '+' || ...
    

    You are guaranteeing to all areas will result in a space, and therefore may not be NULL.
    Lose the spaces before the signs +:

    SELECT  address_line1 || '+' ||
         address_line2 || '+' ||
         address_line3 || '+' || ...
    

    Published by: Frank Kulash on Feb 3, 2010 10:04
    Sorry, my fault. My original post had this error.

  • Case of decode

    Hello
    In this query I used CASE for some conditions. Can I use DECODE instead of CASE? The case statement is bolded.


    SELECT B.cmp_snam_e Buyer_Name,
    a.code Buyer_Ref,
    Open_Date b.enter_dt,
    NVL(a.new_ocl,0) OCL_US$,.
    a.dec_date_g Last_Revision,
    a.new_exp Next_Update,
    b.st1_ref Stat_Ref,
    initcap (c.mtb_desc) status,
    d.source_code Agency_Code,
    d.inf_surs Info_Source_Code,
    d.cbc_req_dt Date_Requested,
    d.crp_date Date_Received,
    CASE
    WHERE (a.os_rec_status IN ('PC'))
    THEN a.os_rec_ref
    WHEN (a.os_rec_status) ("IT", "GA", "CL", "AR")
    THEN
    * (SELECT Pcy_ref *)
    OF con_cla_sub_apr_view
    WHERE CLA_REF = A.OS_REC_REF
    AND byr_ref = a.code
    AND cla_sub =
    * (SELECT MAX (CLA_SUB) FROM con_cla_sub_apr_view WHERE CLA_REF = A.OS_REC_REF*
    *)*
    *)*
    END AS Policy_Ref, e.hst_remark
    Ocl_submission has,.
    companies b,.
    master_tbl c,
    cmp_by_crp d,
    e buyer_remarks
    WHERE A.code = B.cmp_ref
    AND b.st1_ref = c.mtb_ref
    AND a.code = d.cmp_ref
    AND a.code = e.hst_byr_ref (+)
    AND B.cmp_type = 'BYR.
    AND B.st1_ref = "ST1-00054'."
    AND (b.enter_dt > =: FROM_DATE)
    AND b.enter_dt < =: TO_DATE)
    AND A.SEQ =
    (SELECT MAX (SEQ) - 1 FROM ocl_submission WHERE CODE = B.cmp_ref AND SEQ! = 1).
    )
    AND d.srno =
    (SELECT MAX (TO_NUMBER (srno))
    OF cmp_by_crp
    WHERE cmp_ref = a.code
    AND srno! = 1
    )
    AND (e.hst_byr_ref, e.hst_byr_sub, e.SEQ) IN
    (
    SELECT hst_byr_ref, hst_byr_sub, MAX (SEQ) OF buyer_remarks WHERE
    (hst_byr_ref, hst_byr_sub) IN
    (SELECT hst_byr_ref, MAX (hst_byr_sub)
    FROM buyer_remarks WHERE hst_byr_ref = a.code
    GROUP BY hst_byr_ref)
    Hst_byr_ref GROUP, hst_byr_sub
    );

    Hello

    You can still use DECODE instead (and you can always use CASES instead of DECODE and should almost always).

    I agree with Someoneelse and Alex: this is an example of a situation in this CASE is better than DECODE.

    DECODE ( a.os_rec_status
           , 'PC'           , a.os_rec_ref
                            , DECODE ( INSTR ( ',IT,GA,CL,AR,'
                                      , ',' || a.os_rec_status || ','
                                 )
                          , 0       , NULL
                                   , (
                                 SELECT  pcy_ref
                                 FROM    con_cla_sub_apr_view
                                 WHERE   CLA_REF     = A.OS_REC_REF
                                 AND         byr_ref     = a.code
                                 AND         cla_sub      = (
                                                      SELECT  MAX (CLA_SUB)
                                              FROM       con_cla_sub_apr_view
                                              WHERE       CLA_REF     = A.OS_REC_REF
                                              )
                                 )
                          )
         )
    

    This assumes that os_rec_status never contains commas.

    I can't imagine a situation in which DECODE would be significantly faster this CASE.
    I imagine many situations in which the CASE is significantly faster than DECODE.
    I expect, in this case, THAT CASE is only slightly faster than DECODE.

  • concatenating whole so so otherwise - matter or decode statements

    Hello

    I have a table called t_criteria of columns 'criterion_1', 'criterion_2' and criterion_3' with line for each column being either 'Yes', 'No' or 'not known '. (See the DOF below)

    What I want is a statement that will give the number of criteria which have been fulfilled (i.e. the line 'Yes') in a list separated by commas in a column called 'criteria_met '.

    I know how to do this in excel but do not know how I would go about it in oracle?

    It is a way to do this in excel:

    "= SUBSTITUTE (TRIM (IF(B2="Yes",1,)" ") &" "& IF(C2="Yes",2,)" "") &"" & IF(D2="yes",3,) "" ")),""," ")"

    When column B is criterion_1, column C is criterion_2 and column D is criterion_3.

    I use the database 11g r2


    create the table t_criteria

    (the number (2) of site_id not null,)

    criterion_1 varchar2 (25).

    criterion_2 varchar2 (25).

    criterion_3 varchar2 (25).

    key primary constraint site_id_pk (site_id)

    );

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

    insert into t_criteria values (1, 'Yes', 'No', ' yes');

    insert into t_criteria values (2, 'Yes', 'No', "Ignore");

    insert into t_criteria values (3, 'Yes', 'No', ' yes');

    insert into t_criteria values (4, 'No', 'Yes', ' don't know');

    insert into t_criteria values (5, 'No', "Don't know", "Ignore");

    insert into t_criteria values (6, 'No', 'No', ' yes');

    insert into t_criteria values (7, 'No', "Don't know", "Ignore");

    insert into t_criteria values (8, 'Yes', 'No', "Ignore");

    insert into t_criteria values (9, 'Yes', 'No', "Ignore");

    insert into t_criteria values (10, 'Yes', 'No', "Ignore");

    insert into t_criteria values (11, 'No', 'No', "ignore");

    Hello

    Please try below script

    SELECT REPLACE (TRIM(' ')

    OF DECODE(criterion_1,'Yes',1,'')

    ||' '

    || Decode(criterion_2,'Yes',1,'')

    ||' '

    || (Decode(criterion_2,'Yes',1,'')), "","")

    OF t_criteria;

    Concerning

    Mr. Mahir Quluzade

  • Case logic OF statement?

    The problem:

    In our society, there are several physical tables of the same type of information and data. Instead of storing everything in a single table, they differentiated by the company.

    If the commands that may exist in sales_130 for the United States, but sales_244 to the Germany. Structure wise, they are the same. I have the cursor that identifies the data I need to acquire, and which company resides. So I go by the logistics company to get the data in the correct tables. Unfortunately, I need to join many tables and there are between 50 and 100 fields on that I need to update/delete/insert. Having to build all the SQL for each case when its only the tables that change becomes very tedious and difficult to manage.

    Is there a way I can put a case or something like that in the part OF the clause so I did not do the following:
    IF LOGISTIC_COMPANY = 130 THEN
    
    INSERT INTO TEMP_ABCDEF
     (LOG_COMP, A,B,C,D,E,F)
     SELECT
       244, X.A, X.B, X.C, Y.D, Y.E, Y.F
     FROM
       ABC130 X,
       DEF130 Y
    WHERE 
       X.A = Y.D(+);
       
    COMMIT;
    
    ELSIF LOGISTIC_COMPANY = 244 THEN
     
     INSERT INTO TEMP_ABCDEF
     (LOG_COMP, A,B,C,D,E,F)
     SELECT
       244, X.A, X.B, X.C, Y.D, Y.E, Y.F
     FROM
       ABC244 X,
       DEF244 Y
    WHERE 
       X.A = Y.D(+);
       
    COMMIT;  
    ELSIF ...
    To something like:
     INSERT INTO TEMP_ABCDEF
     SELECT
       130,
       X.A,
       X.B,
       X.C,
       Y.D,
       Y.E,
       Y.F
     FROM
     (  
     IF LOGISTIC_COMP = 130 THEN
       ABC130 X,
       DEF130 Y
     ELSIF LOGISTIC_COMP = 244 THEN
       ABC244 X,
       DEF244 Y
     ELSIF LOGISTIC_COMP = 387 THEN
       ABC387 X,
       DEF387 Y  
     ELSEIF ......
    
     )
    WHERE 
       X.A = Y.D(+);
    I tried different vain things.

    In the light of the foregoing, I will for concept, not the correct syntax to explain because I have no idea how to put into words. There must be a way to simplify the SQL code so that I don't manage the business logic - as in the paintings and without having to rewrite while the IF-THEN-ELSE statements.

    That's what it would look like, assuming that the only thing that changes is that the logistic_company still appears at the end tables:

      EXECUTE IMMEDIATE 'INSERT INTO TEMP_ABCDEF (LOG_COMP, A,B,C,D,E,F) ' ||
                        'SELECT ' || LOGISTIC_COMPANY  || ', X.A, X.B, X.C, Y.D, Y.E, Y.F'
                        'FROM   ABC' || LOGISTIC_COMPANY || ' X, DEF' || LOGISTIC_COMPANY || ' Y ' ||
                        'WHERE  X.A = Y.D(+)';
      COMMIT;
    

    Published by: Thomas Morgan on June 3, 2013 10:29

  • BOX WHEN in DECODE statement

    SELECT v_startdate, v_enddate,
    (CASE WHEN SYSDATE BETWEEN v_startdate AND v_enddate THEN
    'active '.
    ON THE OTHER
    'inactive '.
    Status of END)
    OF correction_tab;

    Could you kindly guide as to how to use DECODE and get the desired result.


    Thank you
    Rami Reddy.

    You can, like this.
    However, the CASE seems much clearer for me so why bother with a DECODING?

    sql> with correction_tab as
      2    ( select trunc(sysdate)-1 as v_startdate, trunc(sysdate)   as v_enddate from dual
      3    union all
      4      select trunc(sysdate)   as v_startdate, trunc(sysdate)+1 as v_enddate from dual
      5    union all
      6      select trunc(sysdate)+1 as v_startdate, trunc(sysdate)+2 as v_enddate from dual
      7    )
      8  SELECT v_startdate
      9  ,      v_enddate
     10  ,      CASE
     11           WHEN SYSDATE BETWEEN v_startdate AND v_enddate
     12             THEN 'active'
     13           ELSE 'inactive'
     14         END status
     15  ,      decode ( sign(sysdate-v_startdate), 1, decode(sign(v_enddate-sysdate), 1, 'active', 'inactive'), 'inactive')
     as status2
     16  FROM correction_tab
     17  /
    
    V_STARTDA V_ENDDATE STATUS   STATUS2
    --------- --------- -------- --------
    12-DEC-12 13-DEC-12 inactive inactive
    13-DEC-12 14-DEC-12 active   active
    14-DEC-12 15-DEC-12 inactive inactive
    
  • CASE with MIN statement?

    I am trying to write a case statement that says what STAT is select E MIN (TERM)
    If there are several TERMS that are both low just choose No. Want a line by ID.
    Is this possible using case?

    Thank you.
    CREATE TABLE DAN_GR2
    (ID    VARCHAR2(12),
    TERM    VARCHAR2(12),
    STAT VARCHAR2(12)) 
    
    INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','5','E')
    INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','2','D')
    INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','9','E')
    INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','5','E')
    INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('2','1','E')
    INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('2','10','E')
    INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('3,'10','D')
    ID      TERM     STAT
    1     5     E
    1     2     D
    1     9     E
    1     5     E
    2     1     E
    2     10     E
    3       10      D
    Here you are
    ID   MIN_TERM   
    1     5     
    2     1
    3     NULL
    Use: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi

    Edited by: Chloe_19 09/12/2012 18:07

    Hello

    So, you don't want to ignore the whole when line stat! = 'E' (that ignores the single row with id = "3"). Put the condition ' stat = 'E' in the sill of the WHERE clause ignores line, so this isn't what you want.
    You want to just ignore the expression column. Put the same condition in a CASE expression that contols only this column.

    Here's one way:

    SELECT       id
    ,       MIN ( CASE
                     WHEN  stat = 'E'
                  THEN     term
                 END
               )          AS min_e_term
    FROM      dan_gr2
    GROUP BY  id
    ORDER BY  id
    ;
    

Maybe you are looking for

  • SAT PRO A60 memory upgrade

    is indicated by the documentation of edgetech corp, I bought a 1 GB PC 2100 DDR SO DIMM Toshiba OEM KTT3614 memory.After installation, the laptop does not start correctly showing a blue screen with the following message: page-fault-the-area non paged

  • Desktop HP Pav 550-040: memory

    Hello all; You are always useful - I have a question. I have a desktop computer Pavilion (HP Pavilion Desktop 550-040), which holds a cap of 16 GB of memory. It has now already 8 is installed and I bought on Ebay what follows below - which is an addi

  • Address bar search does not correctly

    This road after FF4 update. Example- "Yahoo email" by typing in the address bar got right email in the yahoo page. Now, after update, type 'yahoo email' in the address bar search in a regular google results, and I have to click on the link yahoo emai

  • ThinkPad e440 ubuntu red inalámbrica desconeccion

    Buenas queria comentar sober one problem that I am having in una particion wont Xubuntu 14.04, el problema tengo're despues UN rato conectado estar has the coneccion una red inalambrica is desconecta, durante mucho tiempo, pero me sigue las showing r

  • HP Officejet 2622: Officejet 2622 weakest paper

    Paper not feed the printer correctly, causing it to jam. It seems to pull down more on the right side, but then stops. When I remove the paper that it is always wrinkled in the hand left corner 2-3cm. I followed all the steps the video on paper jammi