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.

Tags: Database

Similar Questions

  • Nested to decode

    Hi All-
    I have a requirement where I need to convert a nested in a case statement decode statement here's the scenario


    CASE WHEN CD_FAM_01 = "Y" THEN ' N
    WHEN CD_FAM_02 = 'Y', AND THEN 'Y '.
    WHEN CD_FAM_03 = 'Y', AND THEN 'Y '.
    WHEN CD_FAM_04 = 'Y', AND THEN 'Y '.
    WHEN CD_FAM_05 = 'Y', AND THEN 'Y '.
    WHEN CD_FAM_01 IS SET TO NULL, AND CD_FAM_02 IS SET TO NULL AND CD_FAM_03 IS SET TO NULL AND CD_FAM_04 IS SET TO NULL AND CD_FAM_05 IS NULL THEN 'N.'
    WHEN CD_FAM_01 = ' no AND CD_FAM_02 = ' no AND CD_FAM_03 = 'N AND CD_FAM_04 =' N AND CD_FAM_05 = 'No THEN' don't END

    I am facing a moment torrid in the conversion of this instruction can help me here
    SQL> create table ca_test (cd_fam_01 VARCHAR2(1),cd_fam_02 VARCHAR2(1),cd_fam_03 VARCHAR2(1),cd_fam_04 VARCHAR2(1),cd_fam_05 VARCHAR2(1));
    
    Table created.
    
    Elapsed: 00:00:00.02
    SQL>
    SQL> insert into ca_test VALUES ('Y','Y','Y','Y','Y');
    
    1 row created.
    
    Elapsed: 00:00:00.02
    SQL> insert into ca_test VALUES ('N','Y','Y','Y','Y');
    
    1 row created.
    
    Elapsed: 00:00:00.02
    SQL> insert into ca_test VALUES ('N','N','Y','Y','Y');
    
    1 row created.
    
    Elapsed: 00:00:00.02
    SQL> insert into ca_test VALUES ('N','N','N','Y','Y');
    
    1 row created.
    
    Elapsed: 00:00:00.02
    SQL> insert into ca_test VALUES ('N','N','N','N','Y');
    
    1 row created.
    
    Elapsed: 00:00:00.01
    SQL> insert into ca_test VALUES ('N','N','N','N','N');
    
    1 row created.
    
    Elapsed: 00:00:00.01
    SQL> insert into ca_test VALUES (null,null,null,null,null);
    
    1 row created.
    
    Elapsed: 00:00:00.00
    SQL> insert into ca_test VALUES ('N','N','N',null,null);
    
    1 row created.
    
    Elapsed: 00:00:00.00
    SQL>
    SQL> SELECT
      2    cd_fam_01
      3   ,cd_fam_02
      4   ,cd_fam_03
      5   ,cd_fam_04
      6   ,cd_fam_05
      7   ,DECODE
      8      (CD_FAM_01,'Y','N'
      9                    ,DECODE
     10                      (CD_FAM_02,'Y','Y'
     11                                    ,DECODE
     12                                        (CD_FAM_03,'Y','Y'
     13                                                      ,DECODE
     14                                                          (CD_FAM_04,'Y','Y'
     15                                                                        ,DECODE
     16                                                                           (CD_FAM_05,'Y','Y'
     17                                                                                         ,DECODE
     18                                                                                            (COALESCE
     19                                                                                                 (CD_FAM_01
     20                                                                                                 ,CD_FAM_02
     21                                                                                                 ,CD_FAM_03
     22                                                                                                 ,CD_FAM_04
     23                                                                                                 ,CD_FAM_05),NULL,'N'
     24                                                                                                                 ,DECODE
     25                                                                                                                    (GREATEST(CD_FAM_01
     26                                                                                                                             ,CD_FAM_02
     27                                                                                                                             ,CD_FAM_03
     28                                                                                                                             ,CD_FAM_04
     29                                                                                                                             ,CD_FAM_05),LEAST(CD_FAM_01
     30                                                                                                                                              ,CD_FAM_02
     31                                                                                                                                              ,CD_FAM_03
     32                                                                                                                                              ,CD_FAM_04
     33                                                                                                                                              ,CD_FAM_05),DECODE(GREATEST
     34                                                                                                                                                                   (CD_FAM_01
     35                                                                                                                                                                   ,CD_FAM_02
     36                                                                                                                                                                   ,CD_FAM_03
     37                                                                                                                                                                   ,CD_FAM_04
     38                                                                                                                                                                   ,CD_FAM_05),'N','N'))))))))
     39    FROM ca_test
     40   /
    
    C C C C C D
    _ _ _ _ _ _
    Y Y Y Y Y N
    N Y Y Y Y Y
    N N Y Y Y Y
    N N N Y Y Y
    N N N N Y Y
    N N N N N N
              N
    N N N
    
    8 rows selected.
    
    Elapsed: 00:00:00.02
    

    Sounds good? Furthermore, why are you doing this? The case statement is surely preferable.

  • 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

  • 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
    
  • 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

  • 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
  • Help to DECODE statement

    Hi all

    I have data like this YEAR, to 2 columns ITEM_ID

    A 001
    B 002
    C 003
    A 006
    Z 010

    I want to interview based on criteria of the user of what rank they needed. for some reason I need if users choose Z as a criterion, I need a list of all elements with the class A.

    SELECT * FROM my_tbl WHERE to rank = DECODE (: userprompt, 'A', 'A', 'B', 'B'...') Z', ??) ;

    ?? -im missing how to set the condition, I tried with "* has" but nothing bowed not, obviously, it ranks = ' * Z' and do not return all rows.

    Oracle 10 G.
    PLS NOTE * = not equal symbol, for some reason, it does not appear when I post the thread.,.

    Thanks in advance.

    Published by: [email protected] on Sep 4, 2008 10:30

    This should do the trick:

    where grade = decode(:userprompt,'Z',translate(grade,'A','x'),:userprompt)
    

    Published by: Sentinel on September 4, 2008 10:36

  • using nest if then statements using ABM

    I have a two input, 1 output circuit, as in the attached schema. My third node is set down by the very high resistance voltmeter. What I have is a user defined current source ABM that depends on other parameters in the circuit. I wonder it is what my conditional statement is entered in the right format? Conditions are particularly complex and describe as follows:

    If the voltage difference between V2 and U1 is greater than 0, then the current in the ABM = 10 ^-12

    If this voltage difference that the above is not greater than zero and if (V (1) u (1))<(V(2)-U(1)), then="" the="" abm="" current="" is="">

    Otherwise, if (V (1) u (1)) > = (V (2) u (1)) then the current is (0.1*((-(V(2)-U(1)))^0.35))*0.00001596*(((V(2)-U(1))^2)/2)

    As you can see, they are very complex conditions and my concern is that I can't just type in U1 and get the compiler to understand I want the voltage read on the voltmeter of bottom-node. I think I'm using the correct nesting in the encoding format is: if (T, X, (if(Q,R,S))).

    Any help would be appreciated, and details can be provided.

    I don't know why its not throwing an error for the use of u (1), maybe it's a valid keyword.

    If you want to reference a voltage properly, it should be V (net_name) for single ended voltages (referenced to ground) or V (net1, net2) for differential voltages... For models ABM I suggest turning on net visibility throughout the schematic so that you know the net name to the positive terminal of U1 or anywhere else for that matter.

    I think the syntax you have to if/then/else is correct otherwise.

    Kind regards
    Pat Noonan
    National Instruments

  • Helps the state machine

    Hello everyine,.

    I'm working on a state machine. I saw a few videos of the same thing and I need help.

    I have attached the code below.

    My problem is that I can not jump since the first case at the last.

    After the execution of the first case I want LabVIEW to check fot the Boolean control attached to the function select. I used an operator oux during the operation. If the condition of "TERMINATE" is satisfied that I want him to be the last case of local variable is used to turn off the START light.

    at the moment I can't go to the latter case. I want the code to keep control of the State, and whenever the user presses the button END the LED should turn off little matter the time of execution.

    PL suggest ways to accomplish a task... am still a beginner

    Concerning

    Jalashwa

    Hi Sindhurakshak,

    You are welcome. I think that the problem still resides on the Structure of the event to the State "WBS". I can suggest the following (say that everything always ends by WBS what I understand of your current code):

    Remove select it and create a new case event for Boolean switch «end». Location of the enum to cancel in this case, as shown below:

    The above change means that if the value of "end" Boolean switch is changed (assuming that this will change to true), the case of the event will be held event 'end', which will then the enum value 'End' to the transition of change. Let's say that if the Boolean key 'end' has not changed (which means that has not been pressed), it should run the rest as shown below:

    I'll leave the enum value 'WBS' in the time-out period, assuming you want the State to always run the "WBS" idle state, unless you press the key 'end' to trigger the transition "Terminate".

    It may be useful

    Warm greetings,

    Lennard.C

  • 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

  • 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

  • Tag invalid configuration error - nesting help please!

    I'm a newbie total at CF and inherited this application to my organization.  I get this error:

    Configuration not valid Tag nesting on a CF9 server.

    The application uses the cfoutput with the value of option <>.  It's where he Smothers:

    The error occurred in E:\~mld\Nurse\inc_Patients.cfm: line 125

    123: < cfelse >

    124: < option value = "" > < / option > "."

    125: cfoutput query = "SortedPatients" >

    126: < cfif Len (pid) > < option value = "#registry_id #{#pid #}" > #p_firstname # #p_lastname # < / option > < / cfif > "."

    127: < / cfoutput >

    Here's the complete code < cfform > if it helps.

    < action = "index.cfm cfform" method = "POST" > <!--select a patient--> "

    Select a patient:

    < select name = "P" id = "" >

    < Len (P) cfif >

    < option value = "#P #" > #SelectedPatient_FirstName # #SelectedPatient_LastName # < / option >

    < option value = "" > < / option > "."

    < cfoutput query = "SortedPatients" >

    < cfif P QNE pid and Len (pid) > < option value = "#registry_id #{#pid #" > #p_firstname # #p_lastname # < / option > < / cfif > "}".

    < / cfoutput >

    < cfelse >

    < option value = "" > < / option > "."

    < cfoutput query = "SortedPatients" >

    < cfif Len (pid) > < option value = "#registry_id #{#pid #" > #p_firstname # #p_lastname # < / option > < / cfif > "}".

    < / cfoutput >

    < / cfif >

    < / select >

    < input type = "submit" value = "Get the patient" >

    < input type = "hidden" name = "z" value = "0147134" > <!---0147134: Patients (inc_Patients.cfm)->

    < input type = "hidden" name = "lx" value = "1" > <!--output/update of the patient forms - >

    < / cfform >

    Any help is greatly appreciated.  I try to go into production with this, but I need to get this feature.  Thanks in advance!

    Yes, change the blocks (blocks of closing and) blocks.

  • Help with State Machine user Sequentail events

    I'm trying to create a program using the state machine which include events genreated user to jump between States. Also, I want the program to require a sequence of events to be genreted before entering in some States.

    For example:

    States: Init, idle, a-1, A-2, A-3, B - 1 and stop

    If a-1 State is selected, the user must enter the setting and select the condition A-2.
    The user cannot directly jump without having to access the mode a-1 to A - 2
    If the user selects the a-1 State, he should have the possibility of not input parameter and jump to another State as B-1 or Stop

    State A-3 can be entered automatically by State A-2.

    How to program the machine in order to do what I want? I've updated a sampling program. I'm not sure if I impleted the program properly. The user Panel hangs if I enter State a-1, and then press the Stop button. It does not allow me to leave the a-1 State and forces me to go to State A-2.

    A few other questions:

    -How to initialize all values of boleean to 0 during my Init State?

    -Why is a timeout value?

    Hey there, I developed example of Jacobson on a bit here to illustrate the case "Idle, how far to walk, ' your state machine diagram.

    Some keys on the front panel when you are in the bad condition will do nothing, as you can see, because I only check for buttons, I would like to respond to each State. For example, by pressing "Start on" the State of market won't do anything because this isn't a valid button, but pressing "Quit" will bring you to Idle. To implement the rest of the state machine, it is up to you!

  • Need help nav State active started working on the Web site pages 1 vertical slide...

    Hi guys!

    I created a Web site vertical slide you can see here...

    When you click a navigation button, when it takes you to the relevant slide, the active State should move the Home button to the relevant slide. It works fine without the 3 links on the end to external pages but it is only when these additional links are that something seems to get confused...

    Anyone know how I can get the States of nav working for the slide of the site section?

    Thank you very much and I hope to hear from you.

    SM

    Try this:

    . NAV-collapse: hover,.

    . NAV-collapse: active,.

    . NAV-collapse: focus {}

    background: #e8e8e8;

    }

    Nancy O.

  • 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
    

Maybe you are looking for

  • have xp / firefox lost 21 my location bar help thanks Doug

    Running just put XP to update to fireFox 21. Nowhere Bar befor downloaded new worm fire Fox. missing all the things cool fire Fox must use my favorites to go anywhere on the web. Thank you Doug

  • Is there anywhere a technical manual for the NB100?

    Is there anywhere a technical manual for the NB100? I want to replace my internal hard drive with a bigger and Dona´t want to destroy anything, so a manual for how best to open the NB100 would be good :-) Cola

  • update graphics card for Windows 7

    I just updated my computer from Windows XP to Windows 7. My graphics are blurred, and I can't set the resolution properly. I think I need an update for my graphics card. Help?

  • I can connect with the Administrators account without starting windows in safe mode in win xp pro sp3

    I can connect with the Administrators account without starting windows in safe mode and if yes, how? If I ca not, how can I load the graphics in safe mode drivers as all graphical interfaces are not displayed correctly. Thank you, Andre

  • Addition of playlists

    OK, I'm able to make my rocket to recognize that I have added playlists, using playlists I create in Winamp, however when I open the playlist in my rocket, it shows as completely empty. How can I get the playlists to work? I use Ubuntu.