Alter script to keep values between 1 and 99

Hi guys, I currently have a table (for the sake of this lets call it my_table with a column my_column which is integer) I want to restrict the values of this column to values between 1 and 99 and was wondering how I would build this constraint using a script.
Thanks for any help I may recieve on this.

Adding a check constraint should serve the purpose.
create table t_test
col1 integer
alter table t_test add constraint check_col1_val check (col1 between 1 and 99);
insert into t_test values(1);
insert into t_test values(99);
insert into t_test values(81);
insert into t_test values(0);
insert into t_test values(100);Running the last two insert statements will give you a error
insert into t_test values(0)
Error report:
SQL Error: ORA-02290: check constraint (HI_OWNER.CHECK_COL1_VAL) violated
02290. 00000 -  "check constraint (%s.%s) violated"
*Cause:    The values being inserted do not satisfy the named check
*Action:   do not insert values that violate the constraint.

Similar Messages

  • Hide/show region, keep value between pages ?

    Hi,
    I'm using APEX 3.2.1 with Oracle 10g on Windows XP Pro SP3.
    I have 2 menus (regions) who can be hidden or shown by clicking on an image (like in some IDE). The following javascript is called on the "onClick" event :
    function visibilite(region,image) {
         if (region.style.display == "none")
              region.style.display = "" ;
         else
              region.style.display = "none" ;
         if (image.src.indexOf('gauche.png',1) == -1)
              image.src = image.src.replace('droite.png','gauche.png');
         else
              image.src = image.src.replace('gauche.png','droite.png');
    }It works perfectly, but when I navigate to an other page, the menus are obviously shown by default...
    So I just want to keep the value from the previous page to show or hide my menus in the current page.
    I can add page item in all pages and assign value using the url, but it seems not optimized as I will have a lot of pages (>100).
    I can use an application item too, but I tried and I can not assign a value from javascript, and I don't know if it's a good solution as it will force me to call the javascript function just after the menu will be shown, to quickly hide it.
    does anyone think of another solution ?
    Thanks.
    Yann.

    Create a Page 0 item which will be available on all pages.OMG yes I can use items in page 0 ! I should have think of that :/ Shame on me.
    Application item values can be set from JavaScript using AJAX and an On-Demand Process.Yes I already tried ajax with ODP, my getappitem() function works but my setappitem() function won't assign value to application item, but it's not a problem now, I removed the ajax part and I will use page items :D
    Thank you fac586.
    Yann.

  • Table compare and derive alter script between 2 schemas

    I am in Oracle 10g.
    We are in need to synchronise table structures between two different database.
    and execute the alter script in the target database.
    I have an idea to find the tables which have the table definition changed using all_tab_columns and datbase link;
    A sample of it as below:
    prompt
    prompt columns having same name but difference in datatype or length:
    prompt -------------------------------------------------------------------------
    select
    a.column_name, a.data_type, a.data_length, a.data_scale,a.data_precision,
    b.column_name, b.data_type, b.data_length, b.data_scale,b.data_precision
    from
    all_tab_columns a, all_tab_columns@link b
    where
    a.table_name in (select tablename from test) and
    a.table_name = b.table_name and
    a.column_name = b.column_name and
    a.data_type <> b.data_type or
    a.data_length <> b.data_length or
    a.data_scale <> b.data_scale or
    a.data_precision <> b.data_precision
    prompt columns present in &table1 but not in &table2
    prompt ----------------------------------------------
    select
    column_name
    from
    all_tab_columns@link
    where
    table_name in (select tablename from test)
    minus
    select
    column_name --, data_type, data_length, data_scale, data_precision
    from
    all_tab_columns
    where
    table_name in (select tablename from test) ;
    prompt columns present in &table2 but not in &table1
    prompt ----------------------------------------------
    select
    column_name --, data_type, data_length, data_scale, data_precision
    from
    all_tab_columns@link
    where
    table_name in (select tablename from test)
    minus
    select
    column_name
    from
    all_tab_columns
    where
    table_name in (select tablename from test)
    just looking for idea to derive the alter scripts on these? Please share your ideas on this.

    You don't have to write lots of triggers. You only need to write one trigger e.g :-
    create table ddl_audit
    (audit_date date,
    username varchar2(30),
    instance_number integer,
    database_name varchar2(9),
    object_type varchar2(19),
    object_owner varchar2(30),
    object_name varchar2(128),
    sql_text varchar2(2000));
    create or replace trigger BEFORE_DDL_TRG before ddl on database
    declare
    l_sql_text ora_name_list_t;
    l_count NUMBER;
    l_puser VARCHAR2(30) := NULL;
    l_sql varchar2(2000);
    begin
    l_count := ora_sql_txt(l_sql_text);
    l_puser := SYS_CONTEXT('USERENV', 'KZVDVCU');
    l_count := ora_sql_txt(l_sql_text);
    for i in 1..l_count
    loop
    l_sql := l_sql||l_sql_text(i);
    end loop;
    insert into ddl_audit (audit_date, username, instance_number, database_name, object_type, object_owner, object_name, sql_text)
    values (sysdate, l_puser,ora_instance_num,ora_database_name,ora_dict_obj_type,ora_dict_obj_owner,ora_dict_obj_name,l_sql);
    exception
    when others then
    null;
    end;
    show errors;

  • Sharing complex substitution variable values between ASO and BSO databases

    We have ASO and BSO Essbase database member names with spaces in, and need to store some of these member names in substitution variables. However, this has to be done differently for ASO and BSO, due to calc script syntax requiring double quotes and MDX requiring square brackets. For example:
    ASO:
    &CurWeek value = Week 1
    MDX: [&CurWeek]
    BSO:
    &CurWeek value = "Week 1"
    Calc Script: &CurWeek
    As a result, the substitution variables cannot be shared between the ASO and BSO cubes, since the BSO variable value requires double quotes due to the space in the member name.
    Is there a way to get the above to work with both ASO and BSO? Can the double quotes be escaped in calc script syntax? Or can the double quotes be removed in the MDX formula?

    Hi TimG,
    Apologies for such a late reponse to this, genuinely haven't had a spare second to reply until now!
    Yes, I suspect a complex alias name may be the best solution here, and to remove the spaces from the actual member names.
    I was not aware of the latter part at all. My colleague has confirmed as much on this too - DBAG 11.1.2.1 pp117 & 118:
    "Note: If a substitution variable value is numeric or a member name starting with a
    numeral or containing the special characters referred to above is to be used both
    in MDX and non-MDX situations, create two substitution variables, one without
    the value enclosed in quotation marks and one with the value in quotation marks."
    "To ensure that a new substitution variable value is available in formulas, partition definitions,
    and security filters, stop and restart the application. All other uses of substitution variables are
    dynamically resolved when used."
    This last paragraph is the most concerning since we were planning to be able to update substitution variables values and then access the new values from calc scripts and formulae instantaneously. This quirk is unexpected and a little inconvenient. We may have to look at scheduling a change of substitution variable value overnight, followed by a stop/start of the app ready for the next day, and to work around needing to access changed values instantly.

  • Is it possible to apply conditional formatting to a cell (or range) based upon a LOOKUP query to cell values in another sheet.? I want to alter the formatting (i.e., text and/or cell background color), but not cell content.

    Is it possible to apply conditional formatting to a cell (or range) based upon a LOOKUP query to cell values in another sheet.?
    I want to alter the formatting (i.e., text and/or cell background color), but not the content, of the target cell(s).

    Hi Tom,
    Your LOOKUP formula will return a value that it finds in the "other" table. That value can be used in conditional highlighting rules. (Numbers 3 calls it conditional highlighting, not conditional formatting. Just to keep us awake, I guess, but it works the same).
    Please explain what you are trying to do.
    Regards,
    Ian.

  • Use context to pass value between JPF and Java Control

    hi,
    Can we use context to pass value between JPF and Java Control? It works if i m using InitialContext in the same machine but i dun think it will works if i put Web server and application server in different machine. Anyone have an idea how to do it?
    I also want to get the method name in the onAcquire callback method. Anyone knows how to do this?
    thks
    ?:|

    Hi.
    Yoy can the next options for make this:
    1. Pass your values in http request.
    example: http://localhost/index.jsp?var1=value1&var2=value2&var3....
    2. You can use a no visible frame (of height or width 0) and keep your variables and values there using Javascript, but of this form, single you will be able to check the values in the part client, not in the server. Of this form, the values of vars are not visible from the user in the navigation bar.
    Greeting.

  • Problem exchanging values between a Servlet and Thread???

    Hi Everybody,
    I have got a problem exchanging values between a Servlet and a Thread...
    The actual thing will go like this
    I take a request from JSP which is served by a servlet..
    A thread is invoked in the servlets into which the parameter values taken from JSP page is sent...
    In between the thread needs to be suspended for a moment, relieve the control back to the servlet and then come back with the new values modified in the servlet...
    How is this achieved?
    Please give ur suggestions regarding this...
    Thanks in advance

    I really have no clue how you can use URLConnection to do that!
    Could you please explain in the following scenario how it can help me as an alternative solution to the following:
    Non-Servlet A continously running & saving to some prop regularly
    --> servlet B reads prop file regularly --> display continously on a jsp file
    I wish I could do a servlet A --> servlet B-- > display jsp scenario but I do not know how to have servlet A continously running while keep the servlet B interacting with the jsp.

  • GET function fails to get values between 1 and 0

    Hi i have the folowing code
    GET(CONTAVENDAS="PERCVOLUMECORP",FONTEDADO="INPUT",TEMPO="2011.INP",PRODUTO="%SPECIE%_IN",CANAL="NACANAL",ORGCOMERCIAL="NAORGCOM")
    When the value in the PERCVOLUMECORP account, is greater or equal to 1 let's say 80, the get function returns me the correct value, but when i have a value between 0 and one, for instance 0,25, the get function returns 0 (zero)
    Any ideas?
    Thanks in advance.
    Leandro
    Brasil

    Here is the entire script
    **SELECT(%ANO_BD_TRAB%,[YEAR],CATEGORIA,"ID='BDTRABALHO'")
    **SELECT(%ANO_BD_TRAB1%,[YEAR]+1,CATEGORIA,"ID='BDTRABALHO'")
    **SELECT(%ANO_BD_TRAB2%,[YEAR]+2,CATEGORIA,"ID='BDTRABALHO'")
    **SELECT(%MES_INCIO%, STARTMTH, CATEGORIA, "ID='BDTRABALHO'")
    **SELECT(%MESES%,[ID],TEMPO,"MONTHNUM>=%MES_INCIO% AND YEAR=%ANO_BD_TRAB% AND LEVEL='MONTH'")
    **SELECT(%MESES1%,[ID],TEMPO,"MONTHNUM>=%MES_INCIO% AND YEAR=%ANO_BD_TRAB1% AND LEVEL='MONTH'")
    **SELECT(%MESES2%,[ID],TEMPO,"MONTHNUM>=%MES_INCIO% AND YEAR=%ANO_BD_TRAB2% AND LEVEL='MONTH'")
    **SELECT(%CONTAS%, [ID], CONTAVENDAS, "TOPDOWNALLOC='Y'")
    *SELECT(%TODOSPROD%, [ID],PRODUTO,"GRUPO='PRODUTO'")
    **SELECT(%SPECIES%, [ID],PRODUTO,"GRUPO='TIPOESPECIE' AND FLAG_TOPDA='N'")
    **SELECT(%SPECIES_IN%, [ID],PRODUTO,"GRUPO='TIPOESPECIE' AND FLAG_TOPDA='Y'")
    *XDIM_MEMBERSET TEMPO = %MESES%,%MESES1%,%MESES2%,%ANO_BD_TRAB%.INP,%ANO_BD_TRAB1%.INP,%ANO_BD_TRAB2%.INP
    *XDIM_MEMBERSET CONTAVENDAS = %CONTAS%,PERCVOLUMECORP
    *XDIM_MEMBERSET PRODUTO = %SPECIES%,%SPECIES_IN%,%TODOSPROD%
    *OLAPLOOKUP VENDAS
      *DIM FONTEDADO="INPUT"
      *DIM TEMPO="2011.INP"
      *DIM PRODUTO="C_IN"
      *DIM CANAL="NACANAL"
      *DIM ORGCOMERCIAL="NAORGCOM"
      *DIM PERCVOL:CONTAVENDAS="PERCVOLUMECORP"
    *ENDLOOKUP
    *FOR %CONTA% = VOLUME
      *FOR %MES% = 2011.JAN
        *FOR %SPECIE% = C AND %SPECIENAME% = CERVEJAS
         *WHEN PRODUTO.SPECIETYPE
         *IS "%SPECIENAME%"
           *WHEN CONTAVENDAS
           *IS "%CONTA%"
             *WHEN TEMPO
             *IS "%MES%"
                    *REC(CONTAVENDAS="%CONTA%",EXPRESSION=LOOKUP(PERCVOL))
             *ENDWHEN
           *ENDWHEN
         *ENDWHEN
        *NEXT
      *NEXT
    *NEXT
    *COMMIT
    Thanks is advance.

  • I use BT Yahoo! but when I try and navigate to email from the home page it keeps jumping between 'connected and waiting for login' and never loads up.

    My internet service provider is BT in the UK. The home page is www.btinternet.com. After I've logged on, the home page displays fine - I can see the summary of my emails in one of the windows on the home page. The problem comes when I click on the mail application. The page then tries to load the email application. However, it never actually loads, it keeps jumping between connected and waiting for login. It never achieves it so I just have to click the 'back' button to get to the home page. I use chrome and ie but neither has this problem.

    I retraced my steps to how i got the Google app:
    App Store icon on Home Screen > Search, at bottom > entered Google
    The first Google App on the screen appears:
    Google logo small g in blue square: Google Search; Open (because it is already installed).  Below that is a picture of the iPod with the usual  Google Search screen.  I have never inserted a link into a discussion group so i hope you can open this. 
    http://https://itunes.apple.com/us/app/google-search/id284815942?mt=8
    Does this bring us any closer? 

  • Difference in value Between BW and R/3

    Hi,
    We are in the process of validating reports .We have observed difference in value for  credit and debit amount fields in BW and for the same data is coming from standard data source 0EN_JVA_2 (Joint venture: Actual line item using delta extraction) we have done full data load. In the data source the data coming from a single field and that is spited based on debit/credit indicator in R/3.
    I need your valuable input on where the problem is for the difference of value between BW and R/3.
    Regards
    Deva

    Hi,
    Is there any filterations in the IP?
    Any data packet deletion activity in the start rountine?
    Any update rule for the key figure is having routine with modifiying the value?
    Kindly check.
    In case if you are seeing number of records, always aggregation happens.
    If the difference is in terms of quantity of the key figure values, kindly check the above three.
    Kindly come to us so that we can suggest
    Hope this helps
    Janardhan Kumar

  • Rebate: Differ "Scale Base Value" between "Statistics" and "Billing Doc"

    Dear SD Expert,
                After I go with Transaction Code :"VOB3" (run report RV15B002), I found that "Scale Base Value" have different value between "Statistics" and "Billing Doc". And the correct value is "Billing Doc". However, the value which shows in my rebate condition now is "Statistic". Thus, my question is
                How can I configure my rebate condition based on "Billing Doc" Value instead of "Statistic"? (I don't want to "Correct backlogs" anytime in changing scales based value.)  Anyone please feel free in suggestion.
    Thanks,
    Prach

    HI,
    This may be useful to you.
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/5612d8545a11d1a7020000e829fd11/content.htm
    Vrajesh

  • My SD video keeps jumping between the upper and lower frames. So the video starts frame blending and blurring in and out.

    My SD video keeps jumping between the upper and lower frames.  So the video starts frame blending and blurring in and out.  The sequence settings are set to
    Editing Mode: DV NTSC 29.97 frames/second. 
    Pixel Aspect Ration: D1/DV NTSC (0.9091)
    Fileds: Lower Field First
    Display Format: 30fps Non-Drop-Frame Timecode
    720 x480

    What is the source of your video, and exactly what is inside your video?
    Report back with the codec details of your file, use the programs below... A screen shot works well to SHOW people what you are doing
    http://forums.adobe.com/thread/592070?tstart=30 for screen shot instructions
    Free programs to get file information for PC/Mac http://mediaarea.net/en/MediaInfo/Download

  • Activity type is mandatory: enter value between 01 and 07

    Hi guys,
    I would like to ask you for help..
    Recently I updated the App CRM Sales to 2.0.3
    Now, when I try to create an activity/task in IPhone(IOs6), it shows me this error "Activity type is mandatory: enter value between 01 and 07".
    Do I need to apply any SAP note?
    Does anybody have any idea?
    Regards,
    Eder.

    Hi Masayuki,
    Thanks again for you help.
    So, When I create an Activity/Task in CRM Backend I don´t have problem. I can see in my mobile device (Iphone).
    The problem is when I try to create a new activity in App CRM Sales (Iphone).
    I think that there is some obligatory field in CRM Backend, but that in App CRM there isn´t to filled in it.
    Thanks,

  • Select just the values between min and max of an accumulated value over day

    Hello Forum,
    a value is accumulated over a day and over a period of time. Next day the value is reseted and starts again to be accumulated:
    with sampledata as (select to_date('09.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 23 val from dual union all
                       select to_date('09.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 29 val from dual union all
                       select to_date('09.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 30 val from dual union all
                       select to_date('09.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 45 val from dual union all
                       select to_date('09.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 60 val from dual union all
                       select to_date('09.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 75 val from dual union all
                       select to_date('09.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 95 val from dual union all
                       select to_date('09.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 17:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 23:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 14 val from dual union all
                       select to_date('10.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 34 val from dual union all
                       select to_date('10.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 58 val from dual union all
                       select to_date('10.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 70 val from dual union all
                       select to_date('10.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('10.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual)
    select   ts, val
    from     sampledata
    order by ts asc;How should I change the select statement to skip all data sets before the first minimum and the duplicates after the maximum of a day in order to get such a result:
    TS     VAL
    09.09.12 06:12     23
    09.09.12 07:12     29
    09.09.12 08:12     30
    09.09.12 09:12     45
    09.09.12 10:12     60
    09.09.12 11:12     75
    09.09.12 12:21     95
    09.09.12 13:21     120
    09.09.12 14:21     142
    10.09.12 06:12     14
    10.09.12 07:12     34
    10.09.12 08:12     58
    10.09.12 09:12     70
    10.09.12 10:12     120
    10.09.12 11:12     142
    10.09.12 12:21     153Thank you

    This solution works perfectly when the accumulated value has its low and its high on the same day. But I found out :( , that there is also data, which has its low yesterday and its high today. For a better understandig of the case, there is a machine, wich is working over 3 Shifts with irregular start and end time. For example Shift1 cann start at 5:50 or at 7:15. The accumulated value of the worked time is accumuated for each shift extra. This solution works for the shift 1 (approximate between 06:00-14:00) and for the shift 2(approximate between 14:00-22:00), because there is the low and the high of the accumulated value on the same day. This solution does not work for the shif 3(approximate between 22:00-06:00), because the high of the accumulated value is or can be the next day.
    So the thread title should be: "Select just the values between min and max of an accumulated value over the same day(today) or over two successive days (yesterday and today)
    Sampledata for shift 1 or shift 2:
    {code}
    with sampledata as (select to_date('09.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
    select to_date('09.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
    select to_date('09.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
    select to_date('09.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
    select to_date('09.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
    select to_date('09.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
    select to_date('09.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 23 val from dual union all
    select to_date('09.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 29 val from dual union all
    select to_date('09.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 30 val from dual union all
    select to_date('09.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 45 val from dual union all
    select to_date('09.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 60 val from dual union all
    select to_date('09.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 75 val from dual union all
    select to_date('09.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 95 val from dual union all
    select to_date('09.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
    select to_date('09.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('09.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('09.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('09.09.2012 17:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('09.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('09.09.2012 23:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 143 val from dual union all
    select to_date('10.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 144 val from dual union all
    select to_date('10.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 145 val from dual union all
    select to_date('10.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 147 val from dual union all
    select to_date('10.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 148 val from dual union all
    select to_date('10.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
    select to_date('10.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
    select to_date('10.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
    select to_date('10.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
    select to_date('10.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
    select to_date('10.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual)
    , got_analytics     AS
         SELECT ts, val
         ,     MIN (val) OVER ( PARTITION BY TRUNC (ts)
                        ORDER BY      ts DESC
                        )      AS min_val_after
         ,     CASE
              WHEN ROW_NUMBER () OVER ( PARTITION BY TRUNC (ts)
                             ORDER BY     val
                             ,      ts     
                             ) = 1          
              THEN -1 -- Impossibly low val
              ELSE LAG (val) OVER ( PARTITION BY TRUNC (ts)
                             ORDER BY      ts
              END           AS prev_val
         ,     MIN (val) OVER (PARTITION BY     TRUNC (ts))
                        AS low_val_today
         ,     NVL ( LAST_VALUE (val) OVER ( ORDER BY ts
                             RANGE BETWEEN UNBOUNDED PRECEDING
                                  AND     ts - TRUNC (ts) PRECEDING
              , -1
              )          AS last_val_yesterday
         FROM sampledata
    SELECT     ts
    ,     val
    FROM     got_analytics
    WHERE     val          <= min_val_after
    AND     val          > prev_val
    AND     (      val     > low_val_today
         OR     val     != last_val_yesterday
    ORDER BY ts
    {code}
    with the expected results:
    {code}
    1     09.09.2012 06:12:02     23
    2     09.09.2012 07:12:03     29
    3     09.09.2012 08:12:04     30
    4     09.09.2012 09:12:11     45
    5     09.09.2012 10:12:12     60
    6     09.09.2012 11:12:13     75
    7     09.09.2012 12:21:24     95
    8     09.09.2012 13:21:26     120
    9     09.09.2012 14:21:27     142
    10     10.09.2012 06:12:02     143
    11     10.09.2012 07:12:03     144
    12     10.09.2012 08:12:04     145
    13     10.09.2012 09:12:11     146
    14     10.09.2012 10:12:12     147
    15     10.09.2012 11:12:13     148
    16     10.09.2012 12:21:24     153
    {code}
    And the sampledata for shift 3 is:
    {code}
    with sampledata as (select to_date('08.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 23 val from dual union ALL
    select to_date('08.09.2012 02:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 45 val from dual union all
    select to_date('08.09.2012 05:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 78 val from dual union all
    select to_date('08.09.2012 06:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 08:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 10:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 12:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 16:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 17:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 19:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 21:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 90 val from dual union all
    select to_date('08.09.2012 22:00:12', 'dd.mm.yyyy hh24:mi:ss') ts, 24 val from dual union all
    select to_date('08.09.2012 22:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 40 val from dual union all
    select to_date('08.09.2012 23:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 68 val from dual union all
    select to_date('09.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 79 val from dual union all
    select to_date('09.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 124 val from dual union all
    select to_date('09.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 125 val from dual union all
    select to_date('09.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 126 val from dual union all
    select to_date('09.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 17:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union all
    select to_date('09.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 127 val from dual union ALL
    select to_date('09.09.2012 22:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 5 val from dual union ALL
    select to_date('09.09.2012 22:51:33', 'dd.mm.yyyy hh24:mi:ss') ts, 23 val from dual union all
    select to_date('09.09.2012 23:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 40 val from dual union all
    select to_date('10.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 50 val from dual union all
    select to_date('10.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 60 val from dual union all
    select to_date('10.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 78 val from dual union all
    select to_date('10.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
    select to_date('10.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 145 val from dual union all
    select to_date('10.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual union all
    select to_date('10.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 146 val from dual)
    , got_analytics AS
    SELECT ts, val
    , MIN (val) OVER ( PARTITION BY TRUNC (ts)
    ORDER BY ts DESC
    ) AS min_val_after
    , CASE
    WHEN ROW_NUMBER () OVER ( PARTITION BY TRUNC (ts)
    ORDER BY val
    , ts
    ) = 1
    THEN -1 -- Impossibly low val
    ELSE LAG (val) OVER ( PARTITION BY TRUNC (ts)
    ORDER BY ts
    END AS prev_val
    , MIN (val) OVER (PARTITION BY TRUNC (ts))
    AS low_val_today
    , NVL ( LAST_VALUE (val) OVER ( ORDER BY ts
    RANGE BETWEEN UNBOUNDED PRECEDING
    AND ts - TRUNC (ts) PRECEDING
    , -1
    ) AS last_val_yesterday
    FROM sampledata
    SELECT ts
    , val
    FROM got_analytics
    WHERE val <= min_val_after
    AND val > prev_val
    AND ( val > low_val_today
    OR val != last_val_yesterday
    ORDER BY ts
    {code}
    with the unexpected results:
    {code}
    - ts val
    1     08.09.2012 00:04:08     23
    2     08.09.2012 22:12:13     40
    3     08.09.2012 23:21:24     68
    4     09.09.2012 22:21:33     5
    5     09.09.2012 22:51:33     23
    6     09.09.2012 23:21:33     40
    7     10.09.2012 00:04:08     50
    8     10.09.2012 01:03:08     60
    9     10.09.2012 02:54:11     78
    10     10.09.2012 03:04:08     142
    11     10.09.2012 04:04:19     145
    12     10.09.2012 05:04:20     146
    {code}
    The result should be:
    {code}
    - ts val
    1     08.09.2012 00:04:08     23
    2     08.09.2012 02:04:08     45
    3     08.09.2012 05:03:08     78
    4     08.09.2012 06:54:11     90
    5     08.09.2012 22:00:12     24
    6     08.09.2012 22:12:13     40
    7     08.09.2012 23:21:24     68
    8     09.09.2012 01:03:08     79
    9     09.09.2012 02:54:11     124
    10     09.09.2012 03:04:08     125
    11     09.09.2012 04:04:19     126
    12     09.09.2012 05:04:20     127
    13     09.09.2012 22:21:33     5
    14     09.09.2012 22:51:33     23
    15     09.09.2012 23:21:33     40
    16     10.09.2012 00:04:08     50
    17     10.09.2012 01:03:08     60
    18     10.09.2012 02:54:11     78
    19     10.09.2012 03:04:08     142
    20     10.09.2012 04:04:19     145
    21     10.09.2012 05:04:20     146
    {code}
    Thank you for your help!

  • Iphone 5 keeps switching between apple and home screen?

    why does my iphone5 keep switching between apple loading screen and home screen?  I can't use it.

    Try this First...
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    Wait for the Apple logo to Appear...
    Usually takes about 15 - 20 Seconds... ( But can take Longer...)
    Release the Buttons...
    http://support.apple.com/kb/ht1430
    If no joy...
    Connect to iTunes on the computer you usually Sync with and Restore
    http://support.apple.com/kb/HT1414
    Make sure you have the Latest Version of iTunes (v11) Installed on your computer
    iTunes free download from www.itunes.com/download

Maybe you are looking for

  • How to add date/time stamp to PDF in Acrobat 9 Pro?

    Hello, I'd like to add a date/time stamp to a PDF so that when I print the document, the current date/time will be printed as well.  Is it possible to do this?  I found the following posting (http://forums.adobe.com/thread/502915), but am not able to

  • Where can i find the BI Java Connector Files (for example: bi_sdk_jdbc.rar)

    Hi, where can i find the BI Java Connector Files: bi_sdk_jdbc.rar bi_sdk_xmla.rar bi_sdk_sapq.rar bi_sdk_odbo.rar Can anyone help me?

  • Once Mac address book synched from iphone and contacts deleted they won't resynch back

    I have a problem and have spent hours researching but to no avail 1. I got a new iphone 4S and put in my mail info from yahoo, gmail and low and behold I had a contact list now in my phone. I thought, "I just love Apple!" 2. I spent all afternoon on

  • Turning On/Off Frame Decorations

    I have a problem - where I need to turn on/off the frame decorations on Internal frames (borderless frames) - using possibly a hot key ? Is there a way to do this ?

  • SCCM Client

    Hi I have an SCCM environment where top root is parent primary, below is primary and below is primary or secondary site. my Query on SCCM client is - will the client of parent primary be installed on all clients and it will discover site code appropr