When case question

Hi all

I want to find the check when sdate > ACE or sdate > date of the day or sdate > edate.

It works by using the Union operator. When I replace it with the case when then statement, correct record are not seized.

Can someone help me to part, I fact the error (or any other means other than the Union)

with t as)

"SELECT id 101, November 23, 2022" as sdate, 24 October 2012 'as', 22/11/2014 like edate Union double

SELECT id 102, 27 November 2012 as sdate, 25 October 2012 'as', 29/11/2014 as edate Union double

SELECT id 103, 11 November 2012 as sdate, 18 October 2012 'as', 22/11/2014 as edate Union double

"SELECT id 104, 11 April 2012 ' as sdate, 10 September 2012 ' as, ' 02 /' 11/2014 as edate double Union

SELECT id 105, 14 November 2012 ' as sdate, 14 October 2012 'as', 14/11/2014 as double edate

)

SELECT id, sdate, stdate, trunc (sysdate) such as current_date,

case when to_date (sdate, 'dd-mm-yyyy') > to_date (, ' dd-mm-yyyy "") then 'sdate is greater than the ACE.

When to_date (sdate, ' dd-mm-yyyy "") > trunc (sysdate) then "sdate is greater than the current date.

When to_date (sdate, 'dd-mm-yyyy') > to_date (edate, ' dd-mm-yyyy "") then 'sdate is superior to edate.

finish as spd

t

Hello

We don't know what you want for the output.  Always show exactly the results you want from the data of the given sample.

You do 3 different comparisons between the dates.  If the dates are independent, then you have 3 different CASE expressions, as the results of which you can unpivot on 3 different lines of output, like this

WITH got_dates AS

(

SELECT id

, TO_DATE (sdate, ' DD/MM/YYYY') AS sdate

, TO_DATE (ACE, ' DD/MM/YYYY') AS

, TO_DATE (edate, ' DD/MM/YYYY') AS edate

T

)

got_spds AS

(

SELECT id, As

, CASE WHEN sdate > ACE "sdate IS superior to ACEs ' END as spd_1

, CASE WHEN sdate > TRUNC (SYSDATE) THEN "sdate is greater than the current date' END as spd_2

, CASE WHEN sdate > edate THEN "sdate is greater than edate' END as spd_3

OF got_dates

)

SELECT id

As

TRUNC (SYSDATE) AS current_date

spd

OF got_spds

UNPIVOT (spd

FOR n (spd_1 AS 1

spd_2 AS 2

spd_3 AS 3

)

)

;

Or you could UNPIVOT 3 dates on 3 different ranks first and then use only 1 CASE expression.  I find the above path.

Tags: Database

Similar Questions

  • When case statement?

    Hi, I have a question: if my case when the statement is correct. "Œuvre" is an alias for the database.

    and BOX WHEN "Work" =: WORK THEN END of TO_CHAR (0) of OTHER 'work' = NVL ('Work' =: WORK, '0')

    Hello TKS -.

    Here is the general syntax for a CASE statement in OBIEE:

    CASE 'Table name' WHEN. "' column name ' = @{variable presentation} THEN"table name ". "' column name ' ELSE '0' END

    Some things to note:
    (1) ' table name '. ' column name ' is the logical naming convention used by OBIEE. You can get these values automatically simply by clicking on the column on the left side of the screen
    (2) variable presentation can be defined using the guests of dashboard, where the user can select a value and have the report reflect these changes.
    (3) to put single quotes around a value is a string, not a number. I guess this based on your post.

    If you use NVL function on the above statement, use the following:

    IFNULL (BOX "Table name" WHEN. "column name" = @{variable presentation} THEN 'table name' "." column name"END ELSE ' 0 ', ' 0')"

    I hope this helps and please assign points if you found it useful!

    Kind regards
    Jason

  • Missing expression error when cases is used as field

    I tried to write an expression that calculates how many days ago a request and return a value defined by the user if the calculation falls under the criteria in the case statement. The SQL view for the query I use is shown below:
    SELECT A.F_POSN_REQUEST_ID, A.F_REQ_ECP_STATUS, TO_CHAR(A.REQUEST_DTTM,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_PROC_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))>60 THEN '>60' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI')) >30 AND <=60 THEN '30 - 60' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))>=15 AND <=30 THEN '15 - 30' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))<15 THEN 'Less Than 15' ELSE NULL END)END)END)END)) 
      FROM PS_F_POSN_REQUEST A 
      WHERE A.F_REQ_ECP_STATUS IN ('I','O','P') 
      GROUP BY  A.F_POSN_REQUEST_ID,  A.F_REQ_ECP_STATUS,  TO_CHAR(A.REQUEST_DTTM,'YYYY-MM-DD-HH24.MI.SS."000000"'),  TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),  TO_CHAR(A.F_REQ_ECP_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),  TO_CHAR(A.F_REQ_ECP_PROC_DT,'YYYY-MM-DD-HH24.MI.SS."000000"')
    When I try to execute the query I get Message = ORA-00936: lack of expression (50 380)

    Any suggestions you could provide to help me clarify this error would be greatly appreciated.

    Published by: 992737 on March 8, 2013 09:07

    Hi, Peter,.

    Peter Gjelstrup wrote:
    ... OR

    select something,
    case your_expression
           when > 60
    then '>60'
           when > 30
    then '>30'
           when > 10
    then '>10'
    .
    etc.
    end
    something_else
    

    It really works when try you it?

    A CASE of Simple Expression (where you have an expression just after the CASE keyword and before the first WHEN) only check for equality. To use the inequality operators (such as >) you must use an Expression looked for CASES , such as

    CASE
       WHEN  exp > 60  THEN ...
       WHEN  exp > 30  THEN ...
    

    Repeat the expression exp each time.

  • Feature WHEN CASE BI Publisher

    I previously used discoverer to our reports and am studying the differences between the two products. I understand that the chalk and cheese, but one thing I will have trouble identifying does the functionality once we use discoverer in BI Publisher.

    An example of usage for our CASE WHEN creating a derived in a report column to convert existing data in a standardized format.

    I imagine that it's quite a simple answer and I just missed it, but there, could someone help me with where I can enter the features of BI publisher.

    I'm not technically good so all the answers with simple words help :-)

    Published by: 943098 on June 27, 2012 03:25

    You can use CASES WHEN in an sql query in a data model. You can also use it in RTF model via "if then else", choose statements etc.

    Take a look at section 4.10 guide BI report designer Editor to use cases/examples: http://docs.oracle.com/cd/E23943_01/bi.1111/e22254.pdf

    Thank you
    Bipuser

  • Captivate crashes when editing Question pool

    Captivate v5.5

    I have a project with 36 questions in a question pool.

    I need to change some of these QP issues but as soon as I start doing this I get the message that Captivate has encountered an error... Sorry... and needs to close. I tried three times and he does it every time.

    I edited questions many times before PS without this problem.

    I do not work via the company network, but I just moved locations of part of my office to another, in which case it means something.

    Can anyone offer suggestions. I am happy to provide more details if necessary.

    Noel

    Great it works very well.

    Just watch it today, if it works fine. Please close the message.

  • Can issue e-mail notifications when answering Questions in the Forum?

    Hello

    I am allowing discussions on the Forum to my workspace. However, I have noticed that email notifications are not delivered to the previous when respondents a defendant answers to a question/topic.

    Is this possible? or configurable through settings?

    I can't find the answer in the help (http://www.oracle.com/technology/products/beehive/beehive_users/2_0/teamcollab.htm).

    Thank you
    Gray

    HI - in the current version (2.0.x), there is no subscription/notification by email exposed through the INTERFACE of Team Collaboration. It is expected to be part of the next version of the line 2.1 (no date available immediately).

    In 2.0, I recommend using RSS feeds for a workspace update on recent activity. You should see the RSS icon in the recent activity that exposes the URL that you can use in your RSS reader. The following is a list of tested & certified RSS readers: Mozilla Thunderbird, FireFox Live Bookmarks, Omea, SharpReader, FeedDemon, NewzCrawler. Two General comments on RSS readers: 1) you need a player that supports the RSS (Outlook 2007 only is not supported autonomous) authenticated RSS readers) 2 on the Web (like reader.google.com) is not able to pass through the firewall on the server of the hive.

    Hope that helps
    -Jason

  • Case question GX620

    I just bought a desktop computer repackaged GX620 and advised to install a hard drive platter in vacant space just below the DVD drive.  This should allow to change the hard drive without opening the case.

    Problem is that to properly install the Board, both parties must be bolted.  So, I have to remove the other side of the case, the opposite side that is normally open.  This would allow access to the passage of the fixing screws.

    Any help to remove this cover is appreciated.

    I guess I made the question more complex that it really is.

    All I want to know is how to get the left side, one generally not removed out of the folder.

  • Sizing when displaying questions size with mobile device

    I have problems with Muse resizing my site when it is used with a mobile device. He cut the left and right sides for some reason any and I do not know the reason.

    Here's how it should look like the base normally. It is at a resolution of 1024 x 786

    Screen Shot 2014-07-15 at 8.59.33 PM.png

    This is what it looks like on my iPhone 5 (note that cut the sides) -here, any help would be GREATLY appreciated. Thank you guys!

    IMG_7180.png

    The cause of this is because your content is located beyond the left edge and right side of the page in Muse. Please see screenshot below.

    See you soon,.

    Vikas

  • Paravirtualization, when other questions and use

    Hi all

    I read a few articles now that it is recommended to use of paravirtualization all the time, even for the lowest of your VM.  I wanted to

    to confirm that this is true and also how can I change an existing VM to use paravirtualization?

    Thank you

    Greg

    Also remember that they are not recommended for locally-connected disks.

  • the cursor backup when you post a question for misspelled words

    When your question in the search the slider box interrupts back or skip spaces, so the issue is full of misspelled words

    The problem is whenever I used Thunderbird. A friend suggested
    I could be in contact with the touchpad without realizing it. That's exactly what
    I did lately. So I disabled the touchpad and it works
    all right now. Had to go to BIOS to do as the function in the manual keys did not.

    Thank you. May soon return once again, but I hope not.

  • CP8: Question title header and progress indicator are absent when published.

    Hello

    I use Mac and publishing as SCORM 2004 (also tried 1.2), responsive project and download of LMS Blackboard v9. When the question has published the headers and the progress indicator are absent from all slides.

    Thank you

    Veronica

    I have more access to the Blackboard. Just a suggestion: try to download SCORM cloud, to see if it's due to the CP file or the LMS.

    A question: do you have change you the main slides for questions?

  • using case when statement or decode unfavorable in where clause

    Hi the gems...

    I have a problem in the following query...
    I try to use when case statement in where clause of a select query.


    Select cr.customer_name. ' - ' || CR.customer_number as cust_name,
    CR. Salary salary
    of customer_details cr
    where (case when ' > ' = ' > ' then ' cr.salary > 5000')
    When ' > ' = ' < ' then ' cr.salary < 5000'
    When ' > ' = '=' and then 'cr.salary = 5000'
    Another null
    (end);


    the expression in the when clause of the statement of the case, when comes from HQ and according to the choice I have to make the where clause.
    That is why, for the execution of the query, I put ' > ' in this place.

    If the original query will look like this (for reference):

    Select cr.customer_name. ' - ' || CR.customer_number as cust_name,
    CR. Salary salary
    of customer_details cr
    where (case when variable = ' > ' then ' cr.salary > 5000')
    When the variable = ' < ' then ' cr.salary < 5000'
    When the variable = '=' and then 'cr.salary = 5000'
    Another null
    (end);


    so, in a real case, if the user selects ' > ' then the filter will be ' where cr.salary > 5000.
    If the user selects ' < ' then the filter will be ' where cr.salary < 5000.
    If the user selects '=', then the filter will be 'where cr.salary = 5000 '.

    but I get the error "ORA 00920:invalid relational operator.

    Help, please... Thanks in advance...

    Hello

    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
           cr.salary                                      as salary
     from customer_details cr
    where (    v_variable = 'bigger'
           and cr.salary > 5000
          )
       or (    v_variable = 'less'
          and cr.salary < 5000
           )
       or (    v_variable = 'eq'
            and cr.salary = 5000
           )
    

    Published by: user6806750 on 22.12.2011 14:56
    For some reason that I can't write in sql "<', '="">", "=".

  • Error 0x800703F1 when trying to make a backup

    Original title: error 0x800703F1 on aHome Premium Vista

    I can't back up my files due to error 0x800703F1. Which is a registry of corrupted data. How can I fix this.

    Hello

    1. when the question is is produced?
    2. you remember of any changes to your machine before the question?

    I suggest that you follow the steps mentioned below.

    Step 1:

    The problem may be related to your security program. I suggest you temporary disable anti-virus and firewall and check.

    Note: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attacks.

    Step 2:

    Run SFC analysis on your machine to verify if this is related to the missing or corrupted system file.
  • Bluetooth device paired without code OK - BUT when you want to use it, I'm wondering for a pairing code

    I have a Bluetooth device that cannot get a pairing code. I carefully checked the three options of bluetooth connection and the 3rd works, i.e. one that allows the pair without using code.

    So I pair without code - and Windows 7 allows me to do.
    BUT when I run the program that connects to the device, I get a pop up Bluetooth asking me a code!
    It is completely buggy and, moreover, I am not allowed to take control - I know exactly what device I want to use, I see in Bluetooth devices, but for "reasons of security MS" I'm not allowed to use it!
    PLEASE HELP SOMEONE
    Hello
     
    1. when the question is is produced?
    2. What is the number of brand and model of your bluetooth device?
     
    I would like to do the following and check if they help.
     
    Step 1:
     
    Temporarily disable all security software and check if the problem persists.
     

    http://Windows.Microsoft.com/en-us/Windows7/disable-antivirus-software
     
    Note: Antivirus software can help protect your computer against viruses and other security threats.  In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attacks.
     
    Step 2:
     
    The problems with Bluetooth devices
     
     
    (Valid also for Windows 7)
     
     
     
  • Internet connection is lost in computer laptop and Xbox when I fill the network.

    Original title: the network bridge is being gay

    well IM one of the problems with my network bridge that I connected to my card built into my laptop and im for my throu xbox wireless bridge the LAN, and unless he is satisfied, I have internet but when I fill my connections he said: no internet access and I can not access the internet on my laptop and now my habit of Wi - Fi allow me to connect to what anyone I don't have the shared option on check and my connection is really horribly slow and its never been this slow before

    Hello
     
    1. when the question is is produced?

    2. you remember of any changes to your machine before the question?
     
    I would like you to follow the steps mentioned below
     
    Step 1:
     
    Instead of bridge, you should be able to share the connection from your laptop.
     
    a. Click Start, click Control Panel
    b. go to your network and sharing Center.
    c. on the left side, click on manage network connections.
    d. right click on your wireless network adapter, click Properties, click the sharing tab, mark the tab to share this connection
    e. click on apply, then try to connect to xbox with your ethernet cable, either incidentally, it must be a crossover cable in order to function.
     
    Step 2:
     
    Disable all security software temporarily and see if the problem still occurs.

    http://Windows.Microsoft.com/en-us/Windows7/disable-antivirus-software
     
    Note: Antivirus software can help protect your computer against viruses and other security threats.  In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attacks.

    Aziz Nadeem - Microsoft Support

    [If this post was helpful, please click the button "Vote as helpful" (green triangle). If it can help solve your problem, click on the button 'Propose as answer' or 'mark as answer '. [By proposing / marking a post as answer or useful you help others find the answer more quickly.]

Maybe you are looking for