sum of column that contains the values in the time format

Hi all

I give you a piece of my code below
SELECT  dif.EMPLOYEE_NUMBER Employee#, dif.FULL_name EmployeeName,
 TO_CHAR(START_DATE,'dd-Mon-rrrr') DOJ ,dif.DEPT_NAME,POSITION , DATE_ENTRAY AttendanceDate,

 to_char(DATE_ENTRAY,'DY') day, TO_CHAR(LNE1,'hh24:mi')TimeIn1 ,TO_CHAR(LNE2,'hh24:mi')TimeOut1,
 
 TO_CHAR(LNE3,'hh24:mi')TimeIn2 ,TO_CHAR(LNE4,'hh24:mi')TimeOut2, TO_CHAR(LNE5,'hh24:mi')TimeIn3 ,

 TO_CHAR(LNE6,'hh24:mi')TimeOut3, to_char(decode(LNE8,null ,

 decode(LNE7,null, decode(LNE6,null, decode(LNE5,null, decode(LNE4,null, decode(LNE3,null,

 decode(LNE2,null,LNE2 ,LNE2 ),LNE3 ),LNE4 ),LNE5 ),LNE6 ),LNE7 ),LNE8 ),'hh24:mi')TimeOuts ,
 
 ACT_HOUR Work_Hrs, 

decode(DLY_ABSENT_TYPE,'Late',DED_ABS ,'Late (Deduction)',DED_ABS,'00:00') Late_Hrs,ACT_OVT Over_Time
 FROM jjj_PUNCH_DATA_EMP_LIST trn , 
 jjj_emp_def dif,jjj_PUNCH_CARD_ELEG ele WHERE trn.EMPLOYEE_NUMBER =dif.EMPLOYEE_NUMBER and   
 ele.EMPLOYEE_NUMBER =trn.EMPLOYEE_NUMBER  and   DATE_ENTRAY between '23-Aug-2009' and  '24-Aug-2009' 

I require to find the sum of column  wrk_hrs
Act_hour or wrk_hrs belongs to table  jjj_PUNCH_DATA_EMP_LIST trn , and the datatype of act_hour is varchar(10 byte)
the values of column act_hrs, (i require the sum of this column)
08:00
07:22
06:08
kindly help
thanking in advance

concerning
Oracle user

Hello

Thanks for posting the CREATE TABLE and INSERT. That really helps.

Do you want 19:33 ' as the output? Which makes it look like 19 hours and 33 minutes. Most people would represent 19.33 hours (i.e. 19 more than 1/3 hours) as 19:20 '. Should not the sum of
' x: 00 ' and
'y: 20' be
"z: 20?

If you really want 19:33 ', see the solution of Hoek.

If you really want 19:20 ', then you were on the right track.
I think that you were trying to do:

WITH  got_total_hours     AS
(
     SELECT SUM (   TO_NUMBER (SUBSTR (act_hour, 1, 2))
                + ( TO_NUMBER (SUBSTR (act_hour, 4, 2))
                  / 60
                  )
                ) AS total_hours
     from      p
)
SELECT        TO_CHAR (FLOOR (total_hours))
       || ':'
       || TO_CHAR ( MOD (total_hours, 1) * 60
               , 'fm00'
               )     AS hh_mm
FROM     got_total_hours
;

Looks like you were trying calculate total_hours in a subquery, then use the total_hour alias in a query Super, which is quite accurate. You're just confused on how to write a subquery.
There are two basic ways to write subqueries:

(1) WITH clause:

WITH  sub_query  AS
(
     SELECT  ...
)
SELECT  ...
FROM      sub_query
;

(2) online review

SELECT     ...
FROM     (     -- Begin sub_query
     SELECT     ...
     )     -- End sub-query
;

Looks like you tried a bit of each method.

In most cases (this included problem) either one will work.
Other problems are much easier by using a WITH clause and WITH clauses are usually easier to read and understand, I recommend that you always use a WITH clause rather than views online.

You can also change the Hoek solution to get the result 19:20 ' without a subquery (or without using any expression complicated, more than once, which is the only reason why I have proposed a subquery). Since date arithmetic Oracle comes from the days, not hours, when the solution of Hoek has calculated the number of hours, you'll have to divide by 24 to get the number of days. If you are using TO_CHAR to fit the time, however, the results can be confusing if the total is 24 hours or more. You might be better off using NUMTODSINTERVAL.

Tags: Database

Similar Questions

  • Addition of constraint not Null to a column that contains null values

    All,

    Could you please suggest me how to add the constraint not null to an existing column that has null values?

    SQL > create table nn (number n, s varchar2 (10));

    Table created.

    SQL > insert into nn values (1, 'test');

    1 line of creation.

    SQL > insert into values nn (2 '');

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > alter table nn edit n number not null;

    Modified table.

    SQL > nn desc;

    Name                                      Null?    Type

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

    N NUMBER NOT NULL

    S                                                          VARCHAR2(10)

    SQL > alter table nn edit n number null.

    Modified table.

    SQL > nn desc;

    Name                                      Null?    Type

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

    N                                                  NUMBER

    S                                                  VARCHAR2(10)

    SQL > alter table nn change s varchar2 (10) not null;

    ALTER table nn change s varchar2 (10) not null

    *

    ERROR on line 1:

    ORA-02296: impossible to activate (SCOTT) - found null values

    SQL >

    Thank you

    Use NOVALIDATE:

    SQL > alter table nn change s varchar2 (10) not null;
    ALTER table nn change s varchar2 (10) not null
    *
    ERROR on line 1:
    ORA-02296: impossible to activate (SCOTT) - found null values

    SQL >
    SQL > alter table nn change s varchar2 (10) not null NOVALIDATE;

    Modified table.

    SQL > insert into values nn (3, null);
    insert into nn values (3, null)
    *
    ERROR on line 1:
    ORA-01400: cannot insert NULL into ('SCOTT'. "' NN '. » S »)

    SQL > select * from nn;

    N S
    ---------- ----------
    1 test
    2

    SQL >

    SY.

  • How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    I have a table whose columns with values such as

    MINNEAŸPOLIS and ¿VV ¿A

    Only the characters that are allowed in this column are alphabets, numbers, spaces, points and supports.

    Please help to write a SQL SELECT with Regexp_like query or any other option.

    Thanks to you all! Under query worked for me. Thank you Frank to explain the concept of hooks inside regexp_like.

    SELECT * FROM testspecial, WHERE REGEXP_LIKE (sampletext, "[^] ^ A - Z ^ a - z ^ 0-9 ^ [^.]") ^ {^} ^]') ;

  • Trouble with the pivot and the columns that contain numbers/spaces

    Hello

    I have trouble with the pivot statement.
    How could I do this just for columns that are numbers?
    How could I do this just for columns that contain spaces?

    Can someone please help?


    based on the documentation of Carsten Czarski
    http://SQL-PLSQL-de.blogspot.com/2007/08/kreuztabellen-in-Oracle11g-SQL-pivot.html

    essentially to help:
    --------------------
    Select deptno, sum (clerk), sum (salesman), sum (manager)
    of (emp) pivot
    Sum (SAL) of EMPLOYMENT
    in ("CLERK" as a 'CLERK', 'SELLER' as 'SELLER', 'MANAGER' as 'MANAGER')
    )
    Deptno group
    --------------------
    DEPTNO SUM (CLERK) SUM (SALESMAN) SUM (MANAGER)
    ---------- ---------- ------------- ------------
    30 950 5600 2850
    20 1900 2975
    10-1300-2450



    I tried to run at my own table:

    NAME MONAT WERT
    -------------------------------------------------- ---------- ----------
    5 Antarctica 404,84
    Asia 7 106,41
    Oceana 2 456,96
    4 the Europe 426,23
    9 Antarctic 537,56
    Europe 9 832,58
    The South America 12 662,41
    Europe 4 422,27
    America of the North 7 312,19
    America of the North 10 148,92

    10 selected lines.


    But running:
    --------------------
    SELECT name, sum (1), sum (2), sum (3), sum (4), sum (5), sum (6), sum (7), sum (8), sum (9), sum (10), sum (11), sum (12)
    (pivot) apex_wksp.demo_pivot2
    Sum (Wert) for monat
    in ('1 ', '2', ' 3', '4 ', '5', '6', '7',' 8 ', ' 9',' 10', ' 11 ', ' 12')
    )
    Group by name
    ;
    --------------------
    led to:
    Antarctica 1 2 3 4 5 6 7 8 9 10 11 12
    North America 1 2 3 4 5 6 7 8 9 10 11 12
    Oceana 1 2 3 4 5 6 7 8 9 10 11 12
    The South America 1 2 3 4 5 6 7 8 9 10 11 12
    Europe 1 2 3 4 5 6 7 8 9 10 11 12
    Asia 1 2 3 4 5 6 7 8 9 10 11 12
    6 selected lines.


    not quite what I expected.





    In addition,
    --------------------
    Select monat, sum (Antarctica), sum (North America), sum (Oceana), sum (South America), sum (Europe), sum (Asia)
    (pivot) apex_wksp.demo_pivot2
    Sum (Wert) name
    ("Antarctic", "North America", "Oceana", "South America", "Europe", "Asia")
    )
    Group by name
    ;
    ---------------------
    ORA 907 results



    I know what the problem is - but how do I do it right?


    using double quotes or replace (ing) space with just underscores seems to garble sql for the unreadable.




    Help, please.



    Thanks in advance,
    Michael Weinberger

    Attention to the rotated default column alias:

    SQL> with demo_pivot2 as (
      2                       select 'Antarctica' name,5 monat,404.84 wert from dual union all
      3                       select 'Asia',7,106.41 from dual union all
      4                       select 'Oceana',2,456.96 from dual union all
      5                       select 'Europe',4,426.23 from dual union all
      6                       select 'Antarctica',9,537.56 from dual union all
      7                       select 'Europe',9,832.58 from dual union all
      8                       select 'South America',12,662.41 from dual union all
      9                       select 'Europe',4,422.27 from dual union all
     10                       select 'North America',7,312.19 from dual union all
     11                       select 'North America',10,148.92 from dual
     12                      )
     13  select name, sum("'1'"),sum("'2'"),sum("'3'"),sum("'4'"),sum("'5'"),sum("'6'"),sum("'7'"),sum("'8'"),sum("'9'"),sum("'10'"),sum("'11'"),sum("'12'")
     14  from demo_pivot2 PIVOT (
     15  sum(wert) for monat
     16  in ('1','2','3','4','5','6','7','8','9','10','11','12')
     17  )
     18  group by name
     19  ;
    
    NAME          SUM("'1'") SUM("'2'") SUM("'3'") SUM("'4'") SUM("'5'") SUM("'6'") SUM("'7'") SUM("'8'") SUM("'9'") SUM("'10'") SUM("'11'") SUM("'12'")
    ------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------- ----------- -----------
    Antarctica                                                    404.84                                      537.56
    North America                                                                       312.19                            148.92
    Oceana                       456.96
    South America                                                                                                                                 662.41
    Europe                                              848.5                                                 832.58
    Asia                                                                                106.41
    
    6 rows selected.
    
    SQL> 
    

    SY.

  • Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value?

    Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value? I need the actual default value for an individual preference.
    Topic: config shows some default values, but I need the source from which everything: config returns to the default value.
    Any help in this direction is greatly appreciated.

    User Agent

    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x 64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    The preferences that are not hidden if they have by default are stored in two JavaScript text files in the Firefox program folder
    You can open them in a tab in Firefox through these links:
    resource:///defaults/pref/firefox.js
    resource:///greprefs/all.js

    (702598/forum/1/702598)

  • I have a table of the adf, I added a column that contains a button that I created, when I click it must remove this row in the table, but it is not, please help

    I have a table of the adf, I added a column that contains a button that I created, when I click it must remove this row in the table, but it is not, please help

    I don't understand. You use vo and eo for you to use business components.

    Again, this kind of code call in trouble.

    You must post the changes to make them visible to the eo find vo. You must then run the query for the changes in the business layer strips then you must update the iterator he table is based on.

    In your code I see that happen, hooch maybe because it is more often than not formatted and undocumented.

    My advice is to do a small test case that you can manage with easy sql. Once you get it to run transfer you the results to the actual application.

    Timo

  • Prepare a document to insert a row that contains the Blob column. Is what sense this correct?

    When we prepare the statement to insert a row that contains the Blob column. Is what sense this correct? And what is the difference? Does anyone know?

    1 Preparestatement.setBlob(parameter number, blob type object)

    2 Preparestatement.setBlob(parameter number, inputstream type object)

    This link shows the test I did.

    https://community.Oracle.com/thread/3680185?SR=Inbox & customTheme = OTN

    When we prepare the statement to insert a row that contains the Blob column. Is what sense this correct? And what is the difference? Anyone know?

    1 Preparestatement.setBlob(parameter number, blob type object)

    2 Preparestatement.setBlob(parameter number, inputstream type object)

    I answered in your other thread and provided a link to the JDBC Dev Guide section, which explains how to work with type LOB and BFILE data.

    Have you read this article from doc?

    Did you read my response to your other thread?

    In java, a BLOB is just the index that gives you access to the content. In your case, you access by selecting a locator BLOB existing and getting his inputstream. This inputstream is what allows you to access the content real blob.

    The Locator is just that; It specifies the LOCATION of the blob content, but NOT the content.

  • I have a pdf file that contains the text if I copy all the text and paste it into Notepad and save the .txt file is it changes the ascii value of the text?

    I have a pdf file that contains the text if I copy all the text and paste it into Notepad and save the .txt file is it changes the ascii value of the text?

    If the encoding is ASCII? Laughing out loud

    Be well...

  • How to filter the records that contains the Spanish character?

    Hello

    I had an obligation to always records based on the Spanish character.

    Kindly guide me for below.

    To filter the records that contains Spanish characters?

    For example, I had a value in the column name as 'Sureshn '.

    My query should return the above folder that contains the Spanish character "N".

    Please do the necessary help / advice on that.

    Thank you
    Orahar

    I don't know what you want, because if you want a? ¢ Analysys and Sureshn, then my previous query is sufficient. However, maybe something like that.

    SQL> ed
    Wrote file afiedt.buf
    
      1  WITH Sample_Data AS (SELECT 'â?¢ Analysys' str FROM DUAL UNION ALL
      2     SELECT 'SureshÑ' str FROM DUAL UNION ALL
      3     SELECT 'ABCD' str FROM DUAL UNION ALL
      4     SELECT 'WXYZ' str FROM DUAL UNION ALL
      5     SELECT 'Saubhik' str FROM DUAL
      6     )
      7     SELECT str AS "Contains other than English" from Sample_Data
      8*    WHERE REGEXP_LIKE(str,'[^[a-z,A-Z,0-9]]*')
    SQL> /
    
    Contains other
    --------------
    â?¢ Analysys
    SureshÑ
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  WITH Sample_Data AS (SELECT 'â?¢ Analysys' str FROM DUAL UNION ALL
      2     SELECT 'SureshÑ' str FROM DUAL UNION ALL
      3     SELECT 'ABCD' str FROM DUAL UNION ALL
      4     SELECT 'WXYZ' str FROM DUAL UNION ALL
      5     SELECT 'Saubhik' str FROM DUAL
      6     )
      7     SELECT str AS "Contains English" from Sample_Data
      8*    WHERE NOT REGEXP_LIKE(str,'[^[a-z,A-Z,0-9]]*')
    SQL> /
    
    Contains Engli
    --------------
    ABCD
    WXYZ
    Saubhik
    
  • Cell that contains the formula paste between spreadsheets

    How do I paste the value of a cell that contains the result of a spreadsheet formula has, in a worksheet cell B and still have the operation of the formula? OS 10.11.14, numbers 3.6.1.

    Hi dad,

    It depends on what you mean by "still have the operation of the formula."

    If simply paste you it into a new table in another document, the formula will be stuck more or less intact, but it will not reference all the cells on the original table. If he refers only the cells on the table where he came from, he can refer to these same cells or cells in the same position relative to the new location on the table to which it is glued. You will have probably the best success with her work on the new table, if you copy and then paste the formula itself, rather than the containing cell.

    Repeat what I have not quite clear in the first line: the numbers documents cannot reference cells in other documents of numbers.

    Kind regards

    Barry

  • How to create a formula that highlights the cell that contains the same data that I type in another cell

    Hi, can someone help me make a formula which detects and highlights the value of the cell that contains the items of data that I entered in another cell? Thank you

    resolved to myself

  • I downloaded an e-mail that contains the music, I deleted the email, but the music continues to play despite having deleted the history etc.

    I down loaded an e-mail that contains the music, I deleted the email, but the music continues on whwenever game that I connect despite having deleted the history etc.

    {Ctrl + J} t0 open downloads window. Right click on this audio file, and then click remove from the list of

  • I just started using my new iMac 27 "and in Mail, I can't find the setting to display a column that shows the number of emails in each folder.  Mavericks, I had this column.  I have checked all the menus and preferences and search online.

    I just started using my new iMac 27 "and in Mail, I can't find the setting to display a column that shows the number of emails in each folder.  Mavericks, I had this column.  I have checked all the menus and preferences and search online.

    Click the triangle next to the Inbox to view the Inbox for each account. Then select the desired mailbox and the information will be displayed in the upper part.

    You are entitled to 90 days telephone support from Apple. Try to contact them.

    Apple Support contact

    Apple Support by email or chat

    Contact Apple Support - phone

  • Hi, I use iTunes 12.3.2.35 on a Windows 7 computer. I don't seem to be able to import files from a CD that contains the files on it as mp3 files. If I launch iTune and then put the CD in, it doesn't appear and I can't drag and drop.

    Hi, I use iTunes 12.3.2.35 on a Windows 7 computer. I don't seem to be able to import files from a CD that contains the files on it as mp3 files. If I start iTunes and then put the CD in, it doesn't appear and I can't drag and drop.

    It would not seem like an audio CD, as a drive in this way is a data disc when it contains mp3 files. You would need to access the file menu in iTunes, manage files here. If you manually manage music, you will need to access it as a regular folder on your computer. In iTunes, go to file > add file to library, and select individual files.

  • The feature you are trying to use is on a network that is not available. Click OK to try again or enter a different path to the folder that contains the installation packagr 'TrayApp.msi'

    Original title: trayapp

    When I open the computer message appears, the component you are trying to use is on a network that is not available. Click OK to try again or enter a different path to the folder that contains the installation packagr 'TrayApp.msi' in the box below.
    C:\Users\user\AppData\Local\Temp\7zS5216\setup\TrayApp\
    When I click ok the message this way that c:\users\user\appdata\local\temp\7zs5216\setup\trayapp\ is not found. Verfy that you have access to this location and try again or try to find the 'TrayApp.msi' in installing a package file from which you can install the product'TrayApp.
    When I try to cancel the warning message, is that an installation package for the TrayApp product is not found. Again the installation again using a valid copy of the 'TrayApp of installation' package. I already uninstalled all HP products, but this message is still bothering me, how to solve this problem?

    Hey Tama,


    -What version of windows is installed on the computer?
    -Have there been recent changes to the computer before the show?
    I recommend you go through the next HP document and check if it helps.
    Hope this information is useful.

Maybe you are looking for