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

Tags: Database

Similar Questions

  • 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

  • ORA-06592: not found CASE when executing CASE statement

    Hello

    I have a table of application where I built a form master detail (table with 33 columns, 13 is not hidden items and rest are hidden).

    When I run the page I get an error "error while rendering page, article. P10_TIME_SAVED_FREQUENCY, ORA-06592: not found when executing CASE statement CASE"

    Error:

    Error during rendering of the element on the page P8_MONEY_SAVED_FLAG.

    ORA-06592: not found CASE when executing CASE statement

    Technical information (only visible to developers)

    is_internal_error: true

    apex_error_code: WWV_FLOW_FORM. UNHANDLED_ERROR

    ora_sqlcode:-6592

    ora_sqlerrm: ORA-06592: not found CASE when executing CASE statement

    Component.type: APEX_APPLICATION_PAGE_ITEMS

    Component.ID: 13345536607188241

    Component.Name: P8_MONEY_SAVED_FLAG

    error_backtrace:

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 1751

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 4241

    ORA-06512: at "APEX_040200.WWV_FLOW_PLUGIN", line 1251

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 977

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 1406

    DEBUG:

    Exploitation forest exception in final_exception_handler:

    SQLERRM: ORA-20987: APEX - error during rendering of the element on the page P8_MONEY_SAVED_FLAG. -

    ORA-06592: not found CASE during the execution of the instruction BOX Backtrace: ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 853 ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 888 ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS"

    line of 3240 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1780 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1950 ORA-06512: at "APEX_040200.WWV_FLOW", line 6725

    How to solve this problem. Please advice

    Oracle Apex Vesion: 4.2.1

    Thank you

    BO123 wrote:

    Hello

    I have a table of application where I built a form master detail (table with 33 columns, 13 is not hidden items and rest are hidden).

    When I run the page I get an error "error while rendering page, article. P10_TIME_SAVED_FREQUENCY, ORA-06592: not found when executing CASE statement CASE"

    Error:

    Error during rendering of the element on the page P8_MONEY_SAVED_FLAG.

    ORA-06592: not found CASE when executing CASE statement

    Technical information (only visible to developers)

    is_internal_error: true

    apex_error_code: WWV_FLOW_FORM. UNHANDLED_ERROR

    ora_sqlcode:-6592

    ora_sqlerrm: ORA-06592: not found CASE when executing CASE statement

    Component.type: APEX_APPLICATION_PAGE_ITEMS

    Component.ID: 13345536607188241

    Component.Name: P8_MONEY_SAVED_FLAG

    error_backtrace:

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 1751

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 4241

    ORA-06512: at "APEX_040200.WWV_FLOW_PLUGIN", line 1251

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 977

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 1406

    DEBUG:

    Exploitation forest exception in final_exception_handler:

    SQLERRM: ORA-20987: APEX - error during rendering of the element on the page P8_MONEY_SAVED_FLAG. -

    ORA-06592: not found CASE during the execution of the instruction BOX Backtrace: ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 853 ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 888 ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS"

    line of 3240 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1780 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1950 ORA-06512: at "APEX_040200.WWV_FLOW", line 6725

    How to solve this problem. Please advice

    Oracle Apex Vesion: 4.2.1

    Post a backtrace of the page see the request and the item type properties and the source / default to the value of the P8_MONEY_SAVED_FLAG element.

    Seems to be similar to ORA-06592 with the page only items appear, which also involved a master/detail form. Can you reproduce this on apex.oracle.com?

  • value of the check box in the insert statement

    I'm hand-coding an insert from the insert record sb construction will do for this application. The values of several form elements are inserted into the fields in the table. The problem that occur is a checkbox value in the form. If the box is checked, all is well and the value is 'True' inserted in the appropriate database field. However, if the checkbox is not checked I get syntax error message. The reason being that, while are passed on to the fields with null null, the checkbox is not transmitted at all. This is evident when changing the method of the form to 'Get' for testing purposes. There is no reference to this field check box in the query string.

    My assumption is that this would require an If statement changing the value of the 'False' check box when the box is blocked. How I would go to this topic. With my knowledge limited to the ASP, I wrote the following, but it doesn't seem to work:

    < input name = "emailprob_mor" type = "checkbox" id = "emailprob_mor" value = "< % If Not (IsNull (Request.Form ("emailprob_cus")) then Response.Write"True") Else Response.Write ("False") End If % >" >

    When you use the boxes, it is better to separate your Request.Form statement and your insert statement:

    cbVal = '0 '.
    If (Request.Form ("emailprob_mor") <> "") then cbVal = Request.Form ("emailprob_mor")

    Then in your SQL statement:

    "& cbVal &"..."

    For your real HTML:

    "" ) then response.write(" checked='checked' ") %>>

    It is true that if the user does not check the box, then it appears as if there is no when it is submitted, that is the reason why he must be given a default value when the record is inserted.

  • Key on the keyboard does not work in firefox box when you type in the web site, but it works everywhere else?

    Key on the keyboard does not work in firefox box when you type in the web site, but it works everywhere else?

    Try Firefox SafeMode to see how it works there.

    A way of solving problems, which disables most of the modules.

    (If you use it, switch to the default theme).

    • You can open the mode without failure of Firefox 4.0 + by pressing the SHIFT key when you use the desktop Firefox or shortcut in the start menu.
    • Or use the Help menu option, click restart with the disabled... modules while Firefox is running.

    Do not choose anything at the moment, just use 'continue in safe mode.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before using the shortcut of Firefox (without the Shift key) to open it again.

    If it's good in Firefox Safe mode, your problem is probably caused by an extension, and you need to understand that one.

    http://support.Mozilla.com/en-us/KB/troubleshooting+extensions+and+themes

    Can be caused by an add-on to the AVG.

    When find you what is causing that, please let us know. It might help others who have this problem.

  • Add items to the combo box when running

    In my program, I want to add int '34' "43", "17"... and let the user choose one of them to the drop-down list box. How can I add items to the combo box when running. Create a property node 'String [] '? I try that, but its screen is "3443". I want to display as "34".

    43

    17

    See attached extract

  • call the statement box inside the case statement

    I am writing a program which requires me to run a statement box inside another case statement. Although this sounds like a simple thing, I need to be able to call the case statement using a sequence structure, where s1 sends the true value to the case, s2, a fake. Then I need to record the results of this instruction box in a text file. Attatched is a simplified version of what I'm trying to do. Please note that the way my program runs may not call the case statement without using a sequence structure, two nesting box instructions is not feasible. I hope someone out there can help me because I was stuck trying to find this for awhile.

    Thank you

    LVStudent wrote:

    [...] I can't call the case statement without using a sequence structure

    Yes you can.  You just need to be smart.

    LVStudent wrote:

    I don't think I can use a state machine to fix this.

    I think you probably can.

    With respect to your original post. What are these s1 and s2 are you talking about?  My opinion on the matter, it is that you want to select a case based on the values of several controls Boolean.  If this is correct, I do this:

    Build your Boolean controls in a table, convert the table number and insert it into the structure of your business.  No button pressed = 0, s1 = only 1, s2 = only 2 both = 3.   This works for Boolean values as much as you want and is an easy way to make a decision that depends on many entries.

  • Selected pass contains a string indicator combo box when you press the Enter key

    Hello

    How to pass selected contains a string indicator combo box when you press the enter keyboard key?

    Right now I use a button to send the command selected in the combox to string indicator.

    The photos shows a combo box with the button that I use to send to the indicator as example.

    After the user selects the text to pass, "send the cmd" button must be pressed to pass the string.

    I need to pass the selected string when the user press enter on the keyboard rather than press the button 'send cmd '.

    Kindly to you needing help.

    Hello

    You can use a structure of the event to capture keystrokes and filter, transmit only the drop-down list box "value of the indicator of channel when you press the return or enter key."

    Let me know it the joint allows an example (in LV 8.6).

  • I started to get a red message box when trying to get updates... "windows cannot find updates" error 80070490

    I started receivine a red message box when trying to get updates... "windows cannot find updates" error 80070490.  I tried this fix only displayed in this field of the error help and have downloaded the fix - it Center, and he is unable to perform the task.  Please let know us what I can do.  Thank you

    Hello

    Please see the following Microsoft KB article:

    You receive an error code "0 x 80070490" when you use Microsoft Update or Windows Update Web sites to install updates:

    http://support.Microsoft.com/kb/958044

    Warning: Before you perform an upgrade in-place, you must be prepared for the worst scenarios that led to your existing data on your computer being deleted. These data include data personal, settings, information about the hardware and software drivers. In case of a worst case scenario, you may have to reinstall all the programs. Make sure that you back up personal data to disks or other external storage devices before performing an upgrade on the spot.

    I hope this helps.

  • Obtaining an e-mail address to get in the box when I start typing a name

    Please can someone tell me what I need to do in order to get an email to arrive in the box when I start typing the name. Is there a box somewhere that needs ticking or something in order to activate the automatic process?

    In Windows Mail, press ALT + T , click Options > send and put a tick in the box of Auto-complete when composing e-mail addresses . Boulder computer Maven
    Most Microsoft Valuable Professional

  • is it possible to hide the system dialog box when app is happening in the background

    Hello

    I want to hide the system dialog box when our application is underway in the background...

    any suggestion would be appreciated

    Thank you

    Ankur

    Use onThumnailed()

    and this, write the code to hide the system dialog box.

    go through this link too:

    https://developer.BlackBerry.com/Cascades/reference/bb__application.html#function-thumbnail

  • My start ORB, replaced by a square gray box when right click on it.

    My start ORB, replaced by a square gray box when right click on it. This grey area also attach with a word of 'start '. How can I solve this problem?

    My start ORB, replaced by a square gray box when right click on it. This grey area also attach with a word of 'start '. How can I solve this problem?

    Hello

    It seems that your office has been changed to the classic theme.

    What just happened when you started the computer? You have a selected Aero theme before this happened?

    First, right-click on the desktop and select Personalize. Try to select one of the Aero themes to see if this solves the problem.

    If this does not work, try to run the Aero troubleshooter.

    Run the Aero convenience store.

    Open Control Panel and type Troubleshooting in the Search box.

    Select Search and solve problems.

    Under appearance and personalization, select display Aero desktop effects.

    In the Troubleshooting Utility dialog box, click the Advanced Options link and place a check mark in the apply repairs automatically option.

    Click Next to start the troubleshooter.

    Let us know the results.

    Thank you for using Windows 7

    Ronnie Vernon MVP
  • Cannot add contacts for the 'To' and 'cc' Box when sending emails

    Original title: emails

    cannot add contacts to the area "to" or "cc" box when sending mail that I only get the option to add addresses to a small drop-down list when I click in these boxes. I tried to uninstall the application and reinstall but made no difference!

    If you click on the "To", "Cc" or "Bcc" once he frequently gives you used, click New and , it gives you the complete list.  You can switch backwards between them by clicking on


    A more permanent solution   For Outlook
    Gear
    Several e-mail settings
    Customize Outlook
    Advanced Privacy settings
    AutoComplete suggestions
    Give suggestions for anyone I contacted (contacts and non-contacts)
    Save
  • Add como a linha of uma coluna in percent total usa formula com BOX WHEN?

    A coluna "% Exc Parcial/Vendas" nao cylindrical na linha total (em vermelho na imagem) o valor product.»»

    Verificar an imagem abaixo as explica better a situation. ´

    Agregação.png

    Hi people,

    The problem was solved by using the solution below.

    Example: BOX WHEN sum (A) > 0 THEN sum (B) /sum (A) * 100 END ELSE 0

    My formula

    BOX WHEN "-Fato Desemp Unidades Venda". " VL implementations' > 0

    THEN ((SOMME (CASE WHEN "-Venda de Unidades de Fato Desemp «.»))) DT settlements"BETWEEN Min ("-given Dimensão Movimento ".) "The data") AND Max ("-given Dimensão Movimento".) " Data")

    THEN "-Fato Desemp Unidades Venda". " VL Exclusao ".

    ELSE 0 END

    ) / SUM ("-Fato Desemp Unidades Venda". "") Locations of VL')

    ) * 100

    )

    ELSE 0 END

    and the rule of the aggregation: global complex server

  • I have Acrobat Pro 10, when I installed the CD player, it has affected the way I was able to move text boxes when I create a form of gall, he has also affected my ability to release and change the properties of the fields /, I'm I suspect m

    I have Acrobat Pro 10, when I installed the CD player, it has affected the way I was able to move text boxes when I create a form of gall, he has also affected my ability to release and change the properties of the fields /, I'm I suspect my off lucky cat Adobe support will not help , nor a cure to.  Is there a place to find updates to Acrobat 10, if I uninstall my current program?  I still have my original CD and paperwork.  Adobe acknowledge that they have created this problem.   I worked very intensively with Acrobat Pro 10 on the form for a non-profit, I do part, and it happened immediately after that I was testing a form I created in Acrobat 10 to test with CD player. Windows 7 operating system

    This is usually due to the function 'Snap to Grid' is enabled. It can be accidentally activated via the keyboard, so this may have been what happened.

Maybe you are looking for

  • iPad Mini is Malfuntioning...

    Hello, I am using ipad mini wifi. I used a day before and it worked perfectly... The next day; It presents the series of questions; 1. the battery is stuck at 49%. His power not detect (not load) or its been detected by the PC. 2 safari does not open

  • Satellite P200-199 4 GB Ram upgrade

    Nice day I'm trying to upgrade a satellite P200-199 2 X 1 GB Ram to 2 X 2 GB Ram. DDR2 When you install the new 2 X 2 GB of Ram, the computer will not start upward.If I install 1 X 2 GB of Ram, the computer starts.If I install 1 X 2 GB and 1 X 1 GB (

  • HP Pavilion X 2 battery is empty when it is in Standby Mode

    I have a HP Pavilion X 2 product number F5W70UA #ABA. I struggled because I bought this just a few months ago. The battery in an hour or 2 whenever I put the machine to sleep (the lid, put in mode 'sleep', etc). I've updated the BIOS and all the late

  • HP Pavilion g6-2318ek

    I can't find drivers for my please sélectionner portable computer help

  • HECI repeated errors on Windows 7 workstation

    I have a PC in network being used in an educational environment that repeated problems with errors in syslog HECI.  Despite the efforts of solving various problems, the request of the student freezes repeatedly.  I did a google search on these type e