Problem with the round function using Date

Hi,
I have a problem with round function for Date. The input is the four digit year which was picked out from say SYSDATE.
In these scenarios the original value should be rounded up and should get the output as shown under rounded column.
Scenario1
Original Rounded
2020 ---> 2020
2021 ---> 2020
2022 ---> 2020
2023 ---> 2020
2024 ---> 2020
2025 ---> 2025
2026 ---> 2025
Scenario2
Original Rounded
2020 ---> 2020
2021 ---> 2025
2022 ---> 2025
2023 ---> 2025
2024 ---> 2025
2025 ---> 2030
2026 ---> 2030
Scenario3
Original Rounded
2020 ---> 2020
2021 ---> 2020
2022 ---> 2020
2023 ---> 2025
2024 ---> 2025
2025 ---> 2025
2026 ---> 2025
Can anyone help with this....Urgent Please
Thanx for your time

1.
SQL> select n,n-mod(n,5) rnd from test;
         N        RND
      2020       2020
      2021       2020
      2022       2020
      2023       2020
      2024       2020
      2025       2025
      2026       2025
2.
SQL> select n,n+(case when mod(n,10) = 0 then 0
  2                   when mod(n,10) < 5 then 5-mod(n,5)
  3                   else 10-mod(n,10)
  4              end) rnd
  5  from test;
         N        RND
      2020       2020
      2021       2025
      2022       2025
      2023       2025
      2024       2025
      2025       2030
      2026       2030
7 rows selected.
3.
SQL> select n,n+(case when mod(n,10) < 3 then mod(n,10)*-1
  2                   when mod(n,10) < 8 then 5-mod(n,10)
  3                   else 10-mod(n,10)
  4              end) rnd
  5  from test;
         N        RND
      2020       2020
      2021       2020
      2022       2020
      2023       2025
      2024       2025
      2025       2025
      2026       2025
      2027       2025
      2028       2030
      2029       2030
      2030       2030
11 rows selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • I 've a problem with the print function of Itunes

    helo , i 've a problem with the print function of Itunes.
    When i'm trying to create a pdf file of my entire library, i've got a partial file of it.
    instead of the entire library (37000 songs - 209GByte) the pdf file contains only 18000 songs (1GB - pdf file).
    Is there any problem with the pdf creation in Itunes ?
    best regards
    Marco
    i mac 20"   Mac OS X (10.4.9)  

    Please read https://forums.adobe.com/thread/1499014
    -try some steps such as changing browsers and turning off your firewall
    -also flush your browser cache so you are starting with a fresh browser
    http://myleniumerrors.com/installation-and-licensing-problems/creative-cloud-error-codes-w ip/
    http://helpx.adobe.com/creative-cloud/kb/failed-install-creative-cloud-desktop.html
    or
    A chat session where an agent may remotely look inside your computer may help
    Creative Cloud chat support (all Creative Cloud customer service issues)
    http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • Is anyone using iPhoto having a problem with the slide show using shatter where it does not let you put a title over photo?

    Is anyone using iPhoto having a problem with the slide show using shatter where it does not let you put a title over photo? It use to work but it no longer lets you place a title over the opening photo.

    Is your signature still current?(iPhoto '08, OS X Mountain Lion (10.8.4))    I can confirm this for iPhoto '11; Shatter will only show the text slide title between the slides. Ken Burns and Classic theme can still be set to overlay the caption and title directly over the slides.

  • Problems with the CrossTable Function "Sort"

    Hello,
    I have a Problem with the "nice" crosstabfunction of the DesignStudio.
    When I create from a datasource the crosstab and enable the function for sorting it is only possible to sort the first column.
    The other columns get the sign into the Header for the sort function, too. But if I click on it, it won't work and sort nothing.
    I'm sure with the old Version of SAP Design-Studio (1.2) it has worked!
    Now we are using 1.4 and u can only sort the first column?????
    Do I anything wrong? I set only the value for the crosstab (Sorting enabled) on true.
    Thank you for help.
    Greets,
    André

    Hello again,
    The Application Looks like:
    Settings:
    Structure:
    I don't have any further JS Coding for this case implemented. I think that this would be not necessary because of the Settings of the crosstab or?
    Greets,
    André

  • I have a problem with the speaker while using viber, Tango and rebtel

    I have upgraded my iPhone 4 to 5.1.1 and in no time I started having a problem with the speaker. It simply doesn't work at all with Viber, Tango  and Rebtel. It works fine with direct calls but not with calls through these applications. I have contacted Tango and Rebtel in this respect but non could help. Is anyone experiencing such problem. is there a solution. Many thanks for your helo

    Thank you. Have given it a try - it sort of works, although doesn't turn up very loud!

  • New ABAP editor: problems with the paste function

    Hi all,
    for a few weeks, I am working with the new frontend editor now. It is great - however, there is a thing I don't understand using the paste function. Let's make an example:
    i put the following lines into clipboard by highlighting the entire lines and pressing CTRL+C
    select * from ztmk
             where kunnr in s_kunnr.
    after pasting (CTRL+C) it shows up like this:
    select * from ztmk
    where kunnr in s_kunnr.
    Is it a bug or a feature?
    Jörg Krause, GEZE GmbH, Germany

    Hi Rich,
    sorry, I actually upgraded my GUI to 23, but the problem is not solved. Look at this code:
      SELECT * FROM ztmk INTO TABLE lt_ztmk
             WHERE messe IN s_messe AND
                   kunnr_berater IN s_kunnr AND
                   status IN s_statu AND
                   ersda IN s_ersda AND
                   NOT namecpl = space AND
                   country IN s_count AND
                   kontaktid IN s_kntid AND
                   lvorm in s_lvorm.
      SELECT * FROM ztmk INTO TABLE lt_ztmk
      WHERE messe IN s_messe AND
      kunnr_berater IN s_kunnr AND
      status IN s_statu AND
      ersda IN s_ersda AND
      NOT namecpl = space AND
      COUNTRY IN s_count AND
      kontaktid IN s_kntid AND
      lvorm IN s_lvorm.
    the lower select-statement has been pasted from the upper one
    Thanks for answering!
    Jörg

  • Some problems with the count function

    Hi Guys,
    I am trying to return following:
    2009 GUESTS NIGHTS between 1 and 5 = 80 guests
    2009 GIESTS NIGHTS between 5 and 10 = 100 guest
    Whe I use the combine with a similar report option (union), I issue the following query:
    SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3 FROM ((SELECT Resort.Resort saw_0, Time."Year" saw_1, "Non Revenue Facts".Nights saw_2, count(Guests."Guest Name") saw_3 FROM GUEST WHERE "Non Revenue Facts".Nights BETWEEN 1 AND 5 GROUP BY saw_1, saw_2, saw_0) UNION (SELECT Resort.Resort saw_0, Time."Year" saw_1, "Non Revenue Facts".Nights saw_2, count(Guests."Guest Name") saw_3 FROM GUEST WHERE "Non Revenue Facts".Nights BETWEEN 1 AND 5)) t1 GROUP BY saw_1, saw_2, saw_0 , saw_3 ORDER BY saw_0
    The query return just the results for nights between 1 and 5.
    I need two columns showing the count of the guests with nights till 5 and one other column showing the count of the guests with nights from 5 to 10.
    Any help would be really appreciated.
    Regards
    Giuliano

    Sorry I did not get this.
    I should still use the union statement and than build the below function in the nights fields?
    What I am trying to achieve is simply how many guests do i have with at least 1 night and max 5 nights
    and how many guests i have with at least 5 nights and a max of 10 nights.
    I should have 2 columns:
    1 label Nights between 1 and 5
    2 label Nights beween 5 and 10
    the count(guests) column should than show how many guests in the first range and how many in the second.
    Regards
    G.

  • No problem with the PAT FUNCTION

    :biggthumbsup:Hi everybody
     Someone said that the PAT option is disabled when the FSB of the cpu exceeds the 210 Mhz. This is not true.!!!!
    I purchased  my MSI 875 NEO FISR2 2 DAY AGO, and when launching the benchmarks with Sandra 2004 pro sp1, the PAT OPTION  was  disabled!!!
    I never use overclocking because i want my PC to be stable because the applications that i use are very demanding( VIDEO EDITING, HUGE FILES ETC)
    Before returning the mainboard back to the shop i purchaced it, i set the option Seargent[/COLOR] in bios section, and the bus comes automatically to 206 Mhz. Or you can do it directly from the bios by selecting the specified option about  loading the turbo function
    After that, i noticed in windows, that the temperature is stable at a very low level, and the most important thing is that,  PAT is now enabled. the memory's voltage is 2.6v and the AGP'S voltage if i remember well about 0.05 v higher. No crashes everything seems  to be ok
     I hope my advice to be usefull to everyone that needs to know about that
    BYE!!!

    For some reason PAT on the MSI motherboards switches off after 218FSB, anywhere else (ASUS,ABIT), PAT stays on all the way up... so why did MSI choose to turn PAT off at this FSB........Some say that PAT is only effective to this FSB after this the benefits disapear, i'm not so sure..... h'mmmmm.

  • HT4515 Problem with the "Wait" function in dialing a number with an extension.

    I inserted a "wait" into phone number, followed by an extension. When I tap the number, it dials the call. Next to the "End" button, there is a button that shows "Dial..." and the extension. HOWEVER, that button is dimmed and will not function. Any ideas?

    I changed in this way:
    FUNCTION COUNT_OBJECT(workflow_name_p IN VARCHAR2, object_type_p IN VARCHAR2) RETURN NUMBER
    IS
    object_present NUMBER;
    object_inserted NUMBER;
    table_name_p VARCHAR2(4000);
    query_stmt VARCHAR2(4000);
    BEGIN
    IF workflow_name_p = 'AIMDailyIngestorWorkflow'
    THEN
    SELECT SUM(B.STOREDOBJS) INTO object_present
    FROM DPCTJOBTYPESTATS B
    WHERE B.WORKFLOW_NAME = workflow_name_p AND B.OBJTYPE=object_type_p;
    SELECT 'AIM.'||B.TABLE_NAME INTO table_name_p
    FROM DPCTSWOBJTYPE B
    WHERE B.OBJTYPE=object_type_p AND SOFTWARE='AIM';
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || table_name_p || ';' INTO object_inserted;
    object_inserted := object_inserted - object_present;
    END IF;
    RETURN object_inserted;
    END COUNT_OBJECT;and now the error is:
    ORA-00911: invalid character
    ORA-06512: at "INFRA.WORKFLOW_STATISTICS", line 504
    00911. 00000 - "invalid character"
    *Cause:    identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    but the line 504 is the blank line higlighted with the ***.
    Why this error? The code seems correct.
    Thanks, bye bye.

  • Problem with the "Wait" function in dialing a number with an extension.

    I inserted a "wait" into phone number, followed by an extension. When I tap the number, it dials the call. Next to the "End" button, there is a button that shows "Dial..." and the extension. HOWEVER, the next calls for other numbers will always show the same "Dial..." and the extension until IOS restart. Any solution?

    Hello,
    Plese see below the correct syntax for the SUM function
    The following examples are applicable to both Basic and Crystal syntax:
    Sum({file.QTY})
    Calculates the sum of all values in the QTY field.
    Sum({orders.AMOUNT}, {orders.CUSTOMER ID})
    Sums (totals) the orders in each group of orders in the Amount field. The orders are separated into groups whenever the value in the Customer ID field changes.
    Sum({orders.AMOUNT}, {orders.DATE}, "monthly") % Sum({orders.AMOUNT })
    Groups values in the Amount field by month, and calculates the sum of the values for each month group as a percentage of the sum of the values for the entire report.
    Sum([{file.AMOUNT}, {file.PRICE}, {file.COST}])
    Sum of values in the Amount, Price, and Cost fields.

  • Problem with the sleep function

    I just purchased my macbook pro 15 inch in July - the first MAC I had. I got a MAC because of all the problems with my pc's in the past and everyone telling me how wonderful they are. Well.... I have had it in the shop 2 times already and ready for a 3rd time. When I put the computer to sleep it is random if it will wake up. I can open the lid and the keyboard will be lit but the screen will be black and nothing will bring the screen up. Another issue is that sometimes when I open the screen the keys will be lighted but after a few seconds the computer will shut off itself. The last time it was in the shop they replaced everything except the hard drive and it would have cost $1600 if it wasn't under warranty. That just isn't acceptable to me. Now it is doing the same things again - again it is random, sometimes it works fine. I have to make another appt now with the genius bar but anyone know why this could be happening? I'm thinking of asking for a new computer - maybe this one is a lemon? Sugestions?

    Apple has no published, hard and fast policy on replacing Macs that can't be repaired satisfactorily. Anecdotally, it seems that after at least three or four failed attempts to repair the same problem in a machine, Apple considers replacing it. But it's all decided case-by-case and is highly discretionary.

  • Problem in the External Function returned data RAW

    Hi,
    I have a problem, I would want to create an external function in Oracle 10g, than given in input a data RAW it gives back in output the value in format raw.
    I have realized such function through language C.
    these are the prototypes of the function
    ORACLE side:
    CREATE OR REPLACE FUNCTION F_RETURN_RAW (inputText IN RAW)
    RETURN RAW                                                                  -- I do not know to return RAW !!!
    AS LANGUAGE C
    NAME "f_Return_Raw"
    LIBRARY C_Library_DAN
    PARAMETERS
    (inputText RAW,
    inputText INDICATOR,
    inputText LENGTH);
    C side:
    ???? f_Return_Raw(CK_BYTE_PTR in_Text,
    short *in_TextInd,
    int *in_TextLen)
    I do not know what to put in place of ????
    someone can help me with some example?
    thanks to all!
    Regards
    Daniele

    Hello I had already seen the package UTL_RAW,
    in particular is CAST_TO_VARCHAR2 that CAST_TO_RAW,
    but these me are useful Oracle side,
    my problem are to give back to Oracle, from side C, one RAW.
    Perhaps it is not possible to give back a RAW directly?
    or I have more probably not understood your suggestion!
    I would want to create a function that he concurred me to make that
    insert into table_example values(f_Return_Raw(RAW_INPUT))
    that the function gives back RAW directly
    Regards
    Daniele

  • Problems with the HP 1441A using the 33120A VXI pnp driver

    Hi,
    I am building a VXI system which incorporates the HP1441A Arb. I am using the 33120A/1441A VXIpnp driver (within LabView 6) and am having some 'issues' with it.
    I am able to see my instrument in the Visa Assistant screens and am able to run a soft front panel but when I try and run any of the instrument control VIs I get the following error code
    Error Code:BFFF0013
    hp33120a Initialize.viDriver Status: (Hex 0xBFFF0013) VI_ERROR_INV_ACC_MODE: Invalid access mode
    In LabView I am able to get a VISA reference for the instrument (although it will still produce the above error). I have closed all other VISA references and nothing is accessing the instrument whilst I am controlling it via LabV
    iew.
    Help!
    Thanks in advance
    Marlon

    Hi,
    I guess the two instruments have a similar command set. I am also guessing that you are using the standard VISA type instrument driver for the 33120A and not the IVI.
    You will have to switch of the Query because the query string returned will have 33120A related text. This should get you passed the Initialisation.
    Have you not tried Agilent web site for a HP1441A driver?
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Problem with the round

    I have a pb of round when I sum 2 doubles ,how can I correct that?
    for example in my program :
    6.1+3.2=9.3000000001
    thanks

    Two routes:
    1. Use java.math.BigDecimal instead.
    2. Display your number using DecimalFormat.

  • Problems with the MM_swapImage function under IE8

    see
    http://www.nataliekarl.com/index.php
    the navigation on mouse over shows always a white line under navigation-image
    Just on IE 8.
    Please help.
    Thanks.

    May I ask why you are using a frameset?

Maybe you are looking for