Query to get the time MIN

Hi all.

How can I get rank with MIN time (DESPITE DAY) (for the first six hours 08:00-14:00, AND the NEXT 6 hours 14:01 to 20:00)
If what follows is my sample
03/05/2012 17:30:00
04/05/2012 17:00:00
10/05/2012 18:00:00
12/05/2012 08:00:00
10/05/2012 07:00:00  
03/05/2012 11:00:00  
my result should be at first six hours 07:00 and 17:00 followed by six)


Thanks in advance for any help

Personally, I do not like to convert dates into strings and vice versa. I think that both arithmetic and precise the date date would perform better.

Here's an alternative:

with t as (
  select to_date('03/05/2012 17:30:00','DD/MM/YYYY HH24:MI:SS') as dt from dual union all
  select to_date('04/05/2012 17:00:00','DD/MM/YYYY HH24:MI:SS') from dual union all
  select to_date('10/05/2012 18:00:00','DD/MM/YYYY HH24:MI:SS') from dual union all
  select to_date('12/05/2012 09:00:00','DD/MM/YYYY HH24:MI:SS') from dual union all
   select to_date('10/05/2012 08:30:00','DD/MM/YYYY HH24:MI:SS') from dual union all
  select to_date('03/05/2012 11:00:00','DD/MM/YYYY HH24:MI:SS') from dual
)
select to_char(min(dt) keep (dense_rank first order by dt-trunc(dt)), 'HH24:MI:SS') hh24miss
from t
group by trunc((extract(hour from to_timestamp(dt))-2)/6)
order by 1;

HH24MISS
--------
08:30:00
17:00:00

Explanation:

-Use the EXTRACT function to get the time. The date must be "converted" in a timestamp date because ANSI does not have the component "hour".
-Subtract the difference of two hours from the time. This will change the interval from 2-8 to 0-6, 8-14-6-12, etc.
-Divide by 6 and truncates the result. This will give 1 what it is from 08:00 to 13:59.59 hours.
-Group by this result, which will all split into groups of ranges of 6 hours.

-Now, in each group, so the component "hour": TRUNC (DT) is the date with time set to 0, DT - TRUNC (DT) is the component "hour".
-Ordering by the component "hour", download the first date that corresponds to the first component of the time.

Published by: stew Ashton on November 16, 2012 17:38

Tags: Database

Similar Questions

  • How to get the time of browser in the project template

    Hello

    With Jdev 11.1.2.3

    How can I get the time to browsers in the model project?

    Groovy accesses the browser time?

    I have to do some calculations (based on the time of the browser) for each row returned by a query. I think it would work if I could get time to groovy browser because I was able to perform the calculation in the SQL of my View object.

    But I can't seem to find how to get browser in Groovy times? Any ideas?

    The other option, is to use JavaScript to get the date of the browser, that should work, but the lines are displayed from a query in an AF:table, I need to apply the calculation to set the color of the table date field based on the calculation of date browser. So a java method should run for each row returned and displayed in the table.

    What senses seem to better you experts? I seem to be in a catch 22 here... Any ideas? And there are items that you can reference?

    Thanks for the help.

    Published by: 966952 on March 11, 2013 05:41

    As I said, you can set the inlinestyle of the field you want to change the background of a method of bean that return a style as appropriat

    // Bean code: the bean is set as requestScope bena in adfc-config.xml
    import javax.el.ELContext;
    import javax.el.ExpressionFactory;
    import javax.el.ValueExpression;
    
    import javax.faces.application.Application;
    import javax.faces.context.FacesContext;
    
    public class TableInlineStyleBean
    {
        public TableInlineStyleBean()
        {
            super();
        }
    
        // get a value
    
        private Object  getValueExpression(String name)    {
            FacesContext facesCtx = FacesContext.getCurrentInstance();
            Application app = facesCtx.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = facesCtx.getELContext();
            ValueExpression lCreateValueExpression = elFactory.createValueExpression(elContext, name, Object.class);
            return lCreateValueExpression.getValue(elContext);
        }
    
        public String getCalculateStyle()    {
            //use expression from table or any other EL to do the calculation
            String val = "#{row.CommissionPct}";
            Object obj = getValueExpression(val);
            String color = null;
            if (obj != null)        {
                Number n = (Number) obj;
                // return red as background if CommissionPct > 0.2
                if (n.floatValue() > 0.2)
                    color = "background-color:Red;";
            }
            return color;
        }
    }
    

    And in the af: table a column (for example CommisionPct)

                                
                                    
                                
    

    Timo

  • How to get the time based on the time zone?

    Hi all

    I try to get timestamp based on the time zone I assign in the computer... for example right now I m CA, if I change the time zone of the computer IS, and use time get Sec.vi, I always get time to CA.

    and not the ACC at EST time... How can I get the time according to the time on my laptop?

    Think I remember vaguely that LV reads this parameter when loading, then try to restart LV after changing the time zone and see if that helps.

  • ETA App should help to get the time and date feature HELP!

    Hi everyone, I'm doing an application where I need to get the time and date of the antone device can help, I know there is a function such as getDate or getTime but im not to know how to use it.

    As far as I know,

    I use this to get the time system (it returns long type)

    System.currentTimeMillis();
    

    After that, you can use SimpleDateFormat to convert date and time

    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy, HH:mm");
    String time = sdf.format(new Date(System.currentTimeMilis()));
    
  • do not get the time zone on the basis of the city.

    Hello guys, I'm getting the time zone based on the region,

    As America/LosAngelies(-8);

    But I want that on the basis of the town as London(-7) and Adeleid (+ 5);

    How can I achieve this. Help, please.

    Resolved.

    Use the method of getDisplayNames (0). For time zones the device all.

  • How to get the time since January 1, 1970 in chain November 19, 2011 21:30

    I need to get the time from 1 jan 1970.I needs time in milliseconds of the chain (November 19, 2011 21:30). This string, I'm the webservice.i need to convert milliseconds to the requirement of the application. Is it possible to do so. Please help me

    Thank you

    splits the string to create a calendar and set its fields to the values of the substring.

    httpdateparser is very particular about the format. and internal it does the same thing as a manual scan would do, I suppose.

  • SQL query to get the NULL records after the last matching flag

    I have a xx1 table with id and flag columns. So I want the data in this table, after the last flag matched. I want that data to id 7 in the rooms. Even if the id 2,3,5 are null flag 'Y' was at 6. ID so I need a query to get the data of the xx1 table after the last correspondence flag (from 7 to 9 id).

    SQL > create table xx1

    2 (identification number,

    3 flag varchar2 (10));

    Table created.

    SQL > insert into xx1 values (1, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (2, null);

    1 line of creation.

    SQL > insert into values xx1 (3, null);

    1 line of creation.

    SQL > insert into xx1 values (4, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (5, null);

    1 line of creation.

    SQL > insert into xx1 values (6, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (7, null);

    1 line of creation.

    SQL > insert into values xx1 (8, null);

    1 line of creation.

    SQL > insert into values xx1 (9, null);

    1 line of creation.

    SQL > select * from xx1.

    FLAG OF THE ID

    ---------- ----------

    1. IS

    2

    3

    4. IS

    5

    6. IS

    7

    8

    9

    9 selected lines.

    SQL >

    Hello

    user11164339 wrote:

    Hi Frank - when I run the query, I don't see the results data.

    I get

    FLAG OF THE ID

    ----- ----------

    7

    8

    9

    What you do differently?

  • need to get the time host was put in the annotation and maintenance mode

    Hi - it is possible to get the time that a host has been in maintenance mode and also seize any annotation is attached to the ESX host in VC?

    Thank you

    ~ Sai

    Also, by using "get-vmhost" twice is redundant since you have channeled from get-vmhost: "E = { get-vmhost $_ |}". Get-vievent ".

    However, your order will be to return the entire event object and look like:

    Name                                    Event

    ----                                    -----

    host {VMware.Vim.EnteredMaintenanceModeEv...

    You can try below instead:

    Get-VMHost |? {$_. ConnectionState-match 'Maintenance'} | Select Name, @{N = 'Time put in MaintMode'; E={($_ | Get-VIEvent |? {$_. FullFormattedMessage-like"* entered maintenance mode *"} (). " Createduserid}}

    But it can still recover multiple events, so a way to get only the last event and time is below:

    Get-VMHost |? {$_. ConnectionState-match 'Maintenance'} | Select Name, @{N = 'Time put in MaintMode'; E={($_ | Get-VIEvent |? {$_. {"FullFormattedMessage-like" * entered maintenance mode * "} | toplayer-last 1). Createduserid}}

  • How can I get the time to a server in JavaScript? Thank you

    Hello I have implemented a JavaScript from Adobe that expire after a certain date. However, the script asks both on the computer that can be changed. I thought that maybe I could get the time from a server NTP, NIST, which cannot be changed. However, I can't understand how to call and get the time server using JavaScript. I heard that JavaScript is client-side, but there is also a side server as well. Is it possible to code in Adobe Acrobat DC? I heard also that time of the OS is different maybe through Microsoft server. Could I get the OS somehow time?

    I've tried ActiveXObject which doesn't seem to work and in a desperate trial of windows.open ("Internet address"). Other thoughts on attempts? Thank you very much!!!

    Other strategies are also welcome having the exact time of the real.

    -Christmas

    The main problem with anything that is based on JavaScript is that it can be turned off easily, in order to place you in the document code will not work. Or a PDF Viewer that can't stand not JavaScript can be used. A form can submit to a server that can return a response that could include the current time.

  • IOM sql Query to get the status of the failed task

    Hello world

    We have an obligation as we need to get the status of a particular task (say Create User in OID - Completed\Rejected status resource) for the particular user. We are able to get the status of the provisioed of resources to the user but not the status of the special mission which is trigerred for the user.can someone put some light on it. We must have the SQL query to do this.

    Thanks in advance.

    Kind regards
    MKN

    Hello
    Use this query to get the status of the task, also check the cooments

    SELECT USR. USR_LOGIN, OSI. SCH_KEY, ANN. SCH_STATUS, STA. STA_BUCKET OF
    OSI, CHS, STA, MIL, TOS, PKG, OUEDRAOGO, USR, OBJ, OST
    WHERE OSI.MIL_KEY = MIL.MIL_KEY
    AND ANN. SCH_KEY = OSI. SCH_KEY
    AND STA. STA_STATUS = SCH. SCH_STATUS
    AND TOS. PKG_KEY = PKG. PKG_KEY
    AND MIL. TOS_KEY = TOS. TOS_KEY
    AND OUÉDRAOGO. USR_KEY = USR. USR_KEY
    AND OUÉDRAOGO. OST_KEY = OST. OST_KEY
    AND OST. OBJ_KEY = OBJ. OBJ_KEY
    AND OSI. ORC_KEY = OUEDRAOGO. ORC_KEY
    AND OBJ. OBJ_NAME = "User AD".
    AND OST. OST_STATUS = "Provisioning" - filter accordinglly
    AND STA. STA_BUCKET = 'pending' - filter accordinglly
    AND PKG. PKG_NAME = "AD User" - filter accordinglly
    AND MIL.MIL_NAME = 'System' - filter accordinglly Validation
    ;
    Thank you
    Kuldeep

  • Query to get the data of the column and the metadata in the same set of results.

    Is it possible to build a query to get the values of the columns in a table and also be able to get some metadata (data type, data_length, data_precision, data_scale) for columns in the same set of results.

    If I use a join, have a common value to join on the two tables?

    you use a cross join, not requiring common values.

    create table T (n number, d date, v varchar2(30));
    insert into T values (1,sysdate,'ABC');
    commit;
    
    select C.column_name, c.data_type, c.data_length,
    case c.column_id
     when 1 then to_char(T.N)
     when 2 then to_char(T.D)
     when 3 then T.V
    end VALUE
    from USER_TAB_COLUMNS C, T
    where C.table_name='T'
    order by c.column_id;
    
  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    
  • Get the timer

    I'm trying to hide an image using the Freehand tool, and whenever I have to zoom in or out, I get the timer. Is this a known problem or is there something I can do to avoid this?

    Richard, it is the price to pay for the large images in combination with several layers. And, as far as I know, other applications have no layers... memory is really tight on these devices.

    Heiner

  • Flex Mobile Application and get the time zone

    Hello

    I need to know the time in a Mobile application in order to perform some calculations.

    The problem is that I need to know the time from the GMT.

    Is there anyway to zone set by the user to detect or somehow get the time?

    not tried but it's any help

    Date

    timezoneOffset : number

    [read-only] The difference, in minutes, between the time universal (UTC) and the local time of the computer.
  • How can I get the time and date appears on a sony cyber-shot camera

    How can I get the time and date appears on a sony cyber-shot camera

    Hi terpmarty,

    What is the model number of the Sony Cybershot camera?
    Instructions for superimposing the date and time are model specific. Some models do not have the ability to superimpose the date and time too. In such a case, you can use the supplied software Picture Motion Browser (PMB) or PlayMemories home (WPH) (Compatible with the Windows operating system) to print the date and time on pictures.

Maybe you are looking for

  • canvas of handwriting

    I downloaded ISO 10 - I got the handwriting of landscape painting and then it wouldn't work or to go in this mode after some time to play with all the new features. I closed the app, restarted the phone and I still do not have the option more.

  • What is the difference between the HX - 90v and HX - 80 coming cameras?

    What is the difference between the HX - 90v and HX - 80 coming cameras? Thank you!

  • Is this an official warning of the virus?

    Today, I think I was victim of a virus. I received the message "http :// apple." com - safetynotice [.] com' As I have never had this before: is it an official warning of the virus?

  • UNABLE TO CONNECT TO A SPECIFIC ADDRESS URL

    Hola, tengo a ipad y baje el ifile Explorer pero cuando cuando intento conectarme has the URL adjudicada direccion me da error y me not of as el device o servidor no responde.

  • Problem of card mother-suggestions

    I have a Desktop Pavilion p6310y and I lost my second mother. He has a Paragon M2N78 - motherboard and said that it is the only one that can be used on this computer. Does anyone know if there is another motherboard that can be used on this computer?