the sum of colum of the result of the sum

Hello
I am calculating total size a group of table A, B, C, using the query below

Select
nom_segment table_name,
Sum (bytes) /(1024*1024) table_size_meg
from dba_extents where owner = 'RDRDBA' and nom_segment IN ('A', 'B', 'C')
and segment_type = 'TABLE '.
Group by nom_segment;

(get results...)
TABLE_NAME, TABLE_SIZE_MEG
Table_a, 69.5
Table_B, 436,5
Table_C, 23.5


My question is how can I change the query above, to get just the result of the total size of the array A, B, C; This means sum the result sum of column.

(so I don't have to use caculator everything more...)

Thank you
Jerry

Hello

You can achieve this by using the sum function.

Fixed-line 300
SET verify OFF
SET pages 40
Mbytes of COLUMN shaped 999,999,999.99 title "Total | NBA
BREAK on report
CALCULATE the AMOUNT OF megabytes on report
Select sum (bytes) /(1024*1024) MBytes, nom_segment dba_segments where owner = 'RDRDBA' and
nom_segment IN ('A', 'B', 'C')
Group by nom_segment;

HTH

concerning

Jafar

Tags: Database

Similar Questions

  • The sum of more of two results of subject area

    Hello

    OBIEE 10 g.

    I have to club two reports from two disciplines into one, and I'm trying to use the results of two features of areas (Union) topic replies.

    But the problem is its production two records each on a SA. I need a sum more than as follows.

    Year Sales_Amt Stock_Qty

    2014 108123 2343

    but his displays currently as follows.

    Year Sales_Amt Stock_Qty

    2343 0 2014

    2014 108123 0



    Appreciate your help on this.


    Thank you,

    HESH

    No hacking is required that is simple enough. Just don't come back to me and request cross-made calculations because you want to explicitly focused on tips and solutions RPD not good answers.

    http://slc02ojq.Oracle.com:7780/Analytics/saw.dll?answers&path=%2Fshared%2FOTN%2FRPD%20evasion%20UNION

    Prodney / weblogic123

  • See the sum of subset question quiz on a blade of results

    I want to show the sum of part only of scores question quiz on a blade of results.

    I want to still follow and record the scores of questions (acting as a series of tests), but show that the score some of these question marks (final quiz) to the user. I read these steps http://blog.lilybiri.com/intermediate-score-slides but I only need a subset. I'm not getting any summing the scores showing the partition on the slide.

    Any suggestions welcome... Michelle

    Even if you need only a subset, the workflow is quite similar. I would create a variable used to store the total score for the questions in this subset. After each question to consider, you add the value of the variable cpQuizInfoLastSlidePointsscored of system to the user variable. At the end of these questions (don't forget the last of them), you will have the total score for this subset in this user variable.

  • Comparison of the results of the performance and the sum of the sum of array elements

    I did a comparison of the performance of "Add table" with 2 other methods (an Add elements and function of ddot BLAS) to see who was the fastest and also to compare their results, given that I was watching a few slight differences.

    Conclusions
    BLAS ddot's quicker (just a little), then add items, then add it in a loop of table

    BLAS ddot and add items table give identical results almost all the time.

    I don't know why add items in a loop manually gives a slightly different result. I understand there are any rounding due to finite precision errors, but why is it different for the 2 other methods?

    This classic of digital computing: the quality of the result depends on the order of operations.

    A simple example is the calculation of a * b / c with a, b, c equal to 25, 200 and 100 respectively. The result should be 50, but if a, b and c are U8, the result depends on the order of operation, as shown in the example below. DBL and data non-entier, the difference is of course that much smaller, but still there are!

    In your case, the difference also stems from the order of operations:

    -in the table add-in, the product of all the elements is calculated first and then the elements of the array are added.

    -in the loop, the addition is performed after each multiplication.

  • Add Colume in the table and display the result in it.

    Hi guru,.
    I have a requirement to add the column to the existing Table. and display the result after calculation.


    Thank you
    Rutu

    Hello

    Please use this referral code snippet:

    Am = (OAApplicationModule) pageContext.getApplicationModule (webBean) OAApplicationModule;
    OAViewObject vo = (OAViewObject) am.findViewObject (""); Give VO name attached to the region of the Table.
    If (vo! = null)
    {
    vo.addDynamicAttribute (""); Addition of ViewAttribute to VO
    }
    VO. Reset();
    VO. Next();

    Do the math you want to

    Definition of the calculated value in the created attribute of VO
    vo.getCurrentRow () .setAttribute ("", );

    I hope that gives you a proper help.
    Please do not hesitate to ask if more Question

    --
    Thank you
    Shrikant

  • calculate the sum of the two columns - display the result in the third column

    Hello

    I have a report and I want to calculate the sum of the two columns of the report and display the total in the third column.

    For example: Sample_My_Report

    Col1 Col2 (Col1 and Col2) Total

    3-7-10


    can someone help me with this question.

    Thank you.

    Hello:

    If your report is an IR you can use the menu "Tool" to add columns calculated at the State

    CITY

  • Formula of the sum in figures

    How do you create a sum of hour, minute column and multiple by a dollars an hour?

    For example,.

    10 h in the B1:B22 column

    $30 / h in C1

    Hi rp,.

    "The hours and minutes" are lasting and if multiplied by a number, will be a result that is also a duration. So the first step is to convert this length to a number that represents the hours (and part of an hour), then multiply this number by a second number that represents the rate of pay in the number of Dollars (and fraction of a Dollar) per hour.

    C2: = DUR2HOURS (B) * C$ 1

    D2: = DUR2HOURS (B) * D$ 1

    The values in the column of the hours are times.

    Values in C1 and D1 are numbers.

    Results in columns C and D are numbers, with the format of the cell value Currency with two decimal places.

    Table built in numbers (Numbers ' 09) v2.3. The formulas are the same in numbers v3.

    Kind regards

    Barry

  • Problem with the sum of the elements of cluster

    Hello

    I have a problem (maybe very simple to solve). I have a cluster with 3 integers inside. I'm building a table of these elements (after unbundling my cluster) and I want to make the sum of all these parts. However, my result is not satisfactory. For example: my table: [255,255,238] and LV shows me the sum of the parts: 236.

    Probe 6 on my printscreen: my table

    The probe 7: operating result of the sum

    What I am doing wrong? Thanks in advance

    Your data type seems to be U8, so the maximum value can not 255. (It's a little hard to read because of the image resizing). Why don't attach you the VI instead?

    If you need the actual amount, you must first convert them to a different representation (for example the U16).

    In addition, what is the purpose of the loop FOR? Since it only works for an iteration, you might as well delete.

  • Erroneous results when you set a function of window with the range option

    Hello

    I'm trying to calculate a moving average of the previous three months (ex: 2014-03 = avg (02-2014, 2014-01, 2013-12)) but the results are not correct back. I tried to check what are the limits of the window of the query below, but I do not understand how oracle calculates their. In the attached photos, you can see the results of the following query:

    Select
       tab. *,

    -first_value (profit) on TSF (CUSTOMER_ID ORDER BY month_id SCORE 3 PREVIOUS LINES).
    -last_value (profit) on lst (CUSTOMER_ID ORDER BY month_id SCORE 3 PREVIOUS LINES).

    first_value(profit) on (PARTITION BY CUSTOMER_ID ORDER BY month_id asc RANGE BETWEEN 3 EARLIER and 1 EARLIER ) fst_1,.

    LAST_VALUE (profit)  more than (PARTITION BY CUSTOMER_ID ORDER BY month_id asc RANGE BETWEEN 3 EARLIER and 1 EARLIER) lst_1,.

    sum (profit)  more than (PARTITION BY CUSTOMER_ID ORDER BY month_id asc RANGE BETWEEN 3 EARLIER and 1 EARLIER ) sum_1/ *,.
    AVG (profit) more avg_1 of (CUSTOMER_ID ORDER BY month_id asc SCORE RANGED from 3 PREVIOUS 1 and EARLIER).
    de (

    Select 201312 month_id,600 CUSTOMER_ID,10 benefit of double Union all the
    Select 201401,600,1 of double Union all the
    Select 201402,600,3 of double Union all the
    Select 201403,600,12 of double Union all the


    Select 201404,600,5 for double Union all the
    Select 201405,600,8 of double Union all the
    Select 201406,600,4 a double Union all the
    Select ( 201407,600,2 from order by double 1) tab

    1 = 1

    Results:

    000013.png

    Range between works on interval increments, not number of lines (for 201402, so 201401, 201399, 201398)  So I think that in your case you want to use lines between

    Select

    Tab.*,

    -first_value (profit) on TSF (CUSTOMER_ID ORDER BY month_id SCORE 3 PREVIOUS LINES).

    -last_value (profit) on lst (CUSTOMER_ID ORDER BY month_id SCORE 3 PREVIOUS LINES).

    FIRST_VALUE (profit) on fst_1 (PARTITION CUSTOMER_ID ORDER BY month_id asc rows EARLIER BETWEEN 3 and 1 PREVIOUS),

    LAST_VALUE (profit) on lst_1 (PARTITION CUSTOMER_ID ORDER BY month_id asc rows EARLIER BETWEEN 3 and 1 PREVIOUS),

    Sum (profit) on sum_1 (PARTITION CUSTOMER_ID ORDER BY month_id asc rows EARLIER BETWEEN 3 and 1 PREVIOUS) / *.

    AVG (profit) more avg_1 (PARTITION OF CUSTOMER_ID ORDER BY month_id asc rows EARLIER BETWEEN 3 and 1 PREVIOUS).

    de)

    Select 201312 month_id, 600 CUSTOMER_ID, 10 all profit double union

    Select 201401,600,1 from all the double union

    Select 201402,600,3 from all the double union

    Select 201403,600,12 from all the double union

    Select 201404,600,5 from all the double union

    Select 201405,600,8 from all the double union

    Select 201406,600,4 from all the double union

    Select 201407,600,2 from dual tab by 1)

    order of month_id

    What do you expect?

    MONTH_ID CUSTOMER_ID PROFIT FST_1 LST_1 SUM_1
    201312 600 10 - - -
    201401 600 1 10 10 10
    201402 600 3 10 1 11
    201403 600 12 10 3 14
    201404 600 5 1 12 16
    201405 600 8 3 5 20
    201406 600 4 12 8 25
    201407 600 2 5 4 17

    8 selected lines.

  • query or pl sql block to display the mentioned result

    create table shirt (color varchar2 (10), number Qty., number s, number m, l, xl, xxl number);

    insert into shirt values ('black', 10, 5,2,1,2,0);

    insert into shirt values ('black', 8, 2,1,2,0,3);

    insert into shirt values ('White', 5, 2,1,1,0,1);

    insert into shirt values ('White', 7, 2,1,2,1,1);

    How to get the bottom of output?

    Expected result:

    G1 G2 QUANTITY

    Black s 7

    Black 3 m

    Black           l                 3

    XL Black 2

    XXL black 3

    White s 4

    White m 2

    white            l                2

    XL white 1

    White xxl 2

    Vinodh

    Correction


    with

    shirt as

    (select "black" color, quantity 10, 5 s, 2 m, 1 l, 2-xl, xxl 0 of all the double union)

    Select 'Black', 8, 2, 1, 2, 0, 3 double Union all

    Select 'White', 5, 2, 1, 1, 0, Union 1 double all the

    Select 'White', 7, 2, 1, 2, 1, 1 double

    )

    Select the color of g1, g2, quantity

    (select color, concerned, sum (m) m, sum (l) l, sum (xl) xl, sum (xxl) xxl

    shirt

    Group by color

    )

    UNPIVOT (quantity for g2 in (as ', m mod', 'l' l, xl as "xl", xxl as a 'xxl'))

    order of g1, decode(g2,'s',1,'m',2,'l',3,'xl',4,'xxl',5,6)

    G1 G2 QUANTITY
    Black s 7
    Black m 3
    Black l 3
    Black XL 2
    Black XXL 3
    White s 4
    White m 2
    White l 3
    White XL 1
    White XXL 2

    Concerning

    Etbin

  • SQL query to display the sum of the values of each June and December

    Hello having problems of construction of a query to the list SQL query to display the sum of the values of each June and December each year.

    My Table;

    TABLE name: MONTH_TERM

    Fields with values:

    TERM_KEYMONTH_ACTUALMONTH_DATE
    8250001/11/2015 0:00
    8245001/12/2015 0:00
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:00
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:00
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    What I would like to see in a query result:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/2015 0:00
    8245001/12/2015 0:00950
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:002525
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:002658
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    ---

    Here's my query:

    Select

    "TERM_KEY,"

    "MONTH_ACTUAL,"

    to_char(MONTH_DATE,'MM/YYYY') MONTH_DATE,

    DEAL to_char (MONTH_DATE, 'MM')

    WHEN '06' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 1 and 6

    AND term_key = 82)

    WHEN '12' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 7 and 12

    AND term_key = 82)

    ELSE null

    END as SIX_MO_CUMM,

    of MONTH_TERM

    where term_key = 82

    It's my results:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/15 0:00
    8245001/12/15 0:003608
    8240501/01/16 0:00
    8240001/02/16 0:00
    8245001/03/16 0:00
    8242501/04/16 0:00
    8243501/05/16 0:00
    8241001/06/16 0:003717
    8240901/07/16 0:00
    8241501/08/16 0:00
    8242001/09/16 0:00
    8242210/01/16 0:00
    8243601/11/16 0:00
    8255601/12/16 0:003608
    8256801/01/17 0:00
    8262401/02/17 0:00

    Any ideas on how to fix would be great

    Select term_key,

    month_actual,

    month_date,

    case mod (to_char (month_date, 'mm'), 6)

    When 0 then sum (month_actual)

    During)

    term_key partition

    order of month_date

    between the previous month '5' interval and the current line

    )

    end '6 MONTHS in TOTAL'

    from tbl

    order of term_key,

    month_date

    /

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 500 NOVEMBER 1ST, 15TH
    82 450 1 DECEMBER 15 950
    82 405 1 JANUARY 16
    82 400 1 FEBRUARY 16
    82 450 1ST MARCH 16
    82 425 1ST APRIL 16
    82 435 1 MAY 16
    82 410 2525 1 JUNE 16
    82 409 1 JULY 16
    82 415 1ST AUGUST 16
    82 420 16 - SEP - 01

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 422 1 OCTOBER 16
    82-436 NOVEMBER 1, 16
    82 556 2658 1 DECEMBER 16
    82 568 1 JANUARY 17
    82 624 1 FEBRUARY 17

    16 selected lines.

    SQL >

    SY.

  • error "result of concatenating string is too long" when I try to run the following code. Help me!

    When I try to perform the following PROCEDURE, he throws me an error:

    Error from line: 2 in command.

    BEGIN

    FACT_UPDATE;

    END;

    Error report-

    ORA-01489: result of concatenating string is too long

    ORA-06512: at "AFLOBIDW. FACT_UPDATE', line 22

    ORA-06512: at line 2

    01489 00000 - "result of concatenating string is too long."

    * Cause: Result of concatenation of string exceeds the maximum size.

    * Action: Make sure that the result is less than the maximum size.

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

    I can't change the logic of the code since I'm trying to do Informatica at the back done and compare performance between Informatica and Oracle DB. Is there another solution for errors? I add only the SQL query that is part of the PROCEDURE for easy viewing. Please help me. Thank you!

    SELECT "UPDATE XXAFL_MON_FACTS_F SET TASK_WID ='"

    || NVL (TO_CHAR (TASK_WID), 'NULL')

    |', EXECUTION_PLAN_WID ='

    || NVL (TO_CHAR (EXECUTION_PLAN_WID), 'NULL')

    || ', DETAILS_WID ='

    || NVL (TO_CHAR (DETAILS_WID), 'NULL')

    |', SOURCE_WID ='

    || NVL (TO_CHAR (SOURCE_WID), 'NULL')

    |', TARGET_WID = '

    || NVL (TO_CHAR (TARGET_WID), 'NULL')

    || ', RUN_STATUS_WID ='

    || NVL (TO_CHAR (RUN_STATUS_WID), 'NULL')

    |', SEQ_NUM ='

    || NVL (TO_CHAR (SEQ_NUM), 'NULL')

    |', NAME = "'

    || NVL (TO_CHAR (NAME), 'NULL')

    || ' ', NO_POSITION = "'

    || NVL (TO_CHAR (INSTANCE_NUM), 'NULL')

    ||'' ', INSTANCE_NAME = "'

    || NVL (TO_CHAR (INSTANCE_NAME), 'NULL')

    || ' ', TYPE_CD = "'

    || NVL (TO_CHAR (TYPE_CD), 'NULL')

    ||'' ', STATUS_CD = "'

    || NVL (TO_CHAR (STATUS_CD), 'NULL')

    ||'' ', START_TS ='

    || DECODE (START_TS, ",' to_date(''e))

    || To_char (START_TS, "mm/dd/yyyy hh)

    ||'' ((', "dd/mm/yyyy hh")')

    || ', END_TS ='

    || DECODE (END_TS, ",' to_date(''e))

    || To_char (END_TS, "mm/dd/yyyy hh)

    ||'' ((', "dd/mm/yyyy hh")')

    |', DURATION = '

    || NVL (TO_CHAR (DURATION), 'NULL')

    |', STATUS_DESC = "'

    || NVL (TO_CHAR (STATUS_DESC), 'NULL')

    || ' ', DBCONN_NAME = "'

    || NVL (TO_CHAR (DBCONN_NAME), 'NULL')

    ||'' ', SUCESS_ROWS ='

    || NVL (TO_CHAR (SUCESS_ROWS), 'NULL')

    || ', FAILED_ROWS ='

    || NVL (TO_CHAR (FAILED_ROWS), 'NULL')

    |', ERROR_CODE = '

    || NVL (TO_CHAR (ERROR_CODE), 'NULL')

    |', NUM_RETRIES ='

    || NVL (TO_CHAR (NUM_RETRIES), 'NULL')

    || ', READ_THRUPUT ='

    || NVL (TO_CHAR (READ_THRUPUT), 'NULL')

    |', LAST_UPD = '

    || DECODE (LAST_UPD, ",' to_date(''e))

    || To_char (LAST_UPD, "mm/dd/yyyy hh)

    ||'' ((', "dd/mm/yyyy hh")')

    |', RUN_STEP_WID = "'

    || NVL (TO_CHAR (RUN_STEP_WID), 'NULL')

    || ' ', W_INSERT_DT = '

    || DECODE (W_INSERT_DT, ",' to_date(''e))

    || To_char (W_INSERT_DT, "mm/dd/yyyy hh)

    ||'' ((', "dd/mm/yyyy hh")')

    |', W_UPDATE_DT = '

    || DECODE (W_UPDATE_DT, ",' to_date(''e))

    || To_char (W_UPDATE_DT, "mm/dd/yyyy hh)

    ||'' ((', "dd/mm/yyyy hh")')

    || ', START_DATE_WID ='

    || NVL (TO_CHAR (START_DATE_WID), 'NULL')

    |', END_DATE_WID = '

    || NVL (TO_CHAR (END_DATE_WID), 'NULL')

    |', START_TIME ='

    || NVL (TO_CHAR (START_TIME), 'NULL')

    |', END_TIME ='

    || NVL (TO_CHAR (END_TIME), 'NULL')

    ||' WHERE INTEGRATION_ID = "'

    || INTEGRATION_ID

    ||''';' AS Column

    OF XXAFL_MON_FACTS_F;

    Hello

    ORA-01489 is one of these error messages that really means what he says. The error message you posted pretty much sums up the situation.

    What version of Oracle are you using?  (You must still include this whenever you have a question.  See the FAQ forum: Re: 2. How can I ask a question on the forums? )

    From 12.1 of the Oracle, there is an option to allow VARCHAR2s in SQL to be as big as 32767octets.  (The default is 4000).

    Otherwise, if you can't change the code, either do not run. or ensure that the concerned channels are quite short so the error does not occur.

  • How to get the sum of "(qty*rate) as salesValue 'as TotalSalesValue cust_id agenda?"

    Mr President.

    I have to take the column values from3, or 4 tables and two of them need to be multiplied, then get the sum of this value multiplied by using Group by and order clause.

    as below

    cust_id prod name Qty. rate value totalValue
    01one01500500
    01b024008001300

    How to get there

    Select

    cstmr.cust_id CustId,

    PRDT. Name AutoCAD,

    SL.sal_qty SalQty,

    SL.unit_sal_price UnitSalPrice,

    SL.sal_qty * SL.unit_sal_price as SalVal,

    Sum(SL.sal_qty*SL.unit_sal_price) as TotalSalesValue

    Of

    cstmr customer,

    salesLine sl,

    prdt product

    where

    PRDT.prod_id = sl.prod_id

    Group

    cstmr.cust_id,

    PRDT. Name,

    SL.sal_qty,

    SL.unit_sal_price

    order by

    cstmr.cust_id

    Concerning

    Your expected results include values that are not in your input data - there is no M.BOARD product, for example. This is an adaptation of Manik code that will give you the subtotals for each customer:

    SELECT client_name c.nom,

    product_name p.Name,

    SL.sal_qty,

    SL.unit_sal_price,

    SL.sal_qty * SL.unit_sal_price AS salesvalue,

    CASE

    WHEN ROW_NUMBER () OVER (partition by order of c.cust_id p.prod_id desc, sl.sal_id desc) = 1 THEN

    SUM (sl.sal_qty * sl.unit_sal_price) OVER (PARTITION BY c.cust_id)

    END totals

    FROM customer c INNER JOIN sales s ON s.cust_id = c.cust_id

    INNER JOIN salesline sl ON sl.sal_id = s.sal_id

    INNER JOIN product p ON p.prod_id = sl.prod_id

    ORDER BY c.cust_id, p.prod_id, sl.sal_id

    You could get the grand total of lines by the Union in a second query, or by doing something smart using ROLLUP. But I leave that to you because I think you should at least do some of your own homework.

  • Ask help - please help me get the expected defined in a query result

    Dear all,

    Help with your suggestions and advice. Please see the bottom of the screenshots for the planned result sets.

    create table shift_dt 
    (name varchar2(20),
    shift_start date,
    shift_end date);
    
    insert into shift_dt values ('Brian',to_date('01-01-2015 09:10:00','dd-mm-yyyy hh24:mi:ss'), to_date('01-01-2015 22:10:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('02-01-2015 09:10:00','dd-mm-yyyy hh24:mi:ss'), to_date('04-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('04-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('05-01-2015 15:20:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('06-01-2015 10:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('06-01-2015 23:20:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('07-01-2015 11:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('09-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('09-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('10-01-2015 22:00:00','dd-mm-yyyy hh24:mi:ss'));
    
    select * from shift_dt;
    
    
    

    Select * from shift_dt;

    1.jpg

    Expected result set: -.

    1.jpg

    I compare date of shift_end with the next date of shift_start of the day. If the dates made 12 am (IE 00:00:00), then I ignore and display the next shift end date available as displayed in the screen game result. Please see the screen set outcome turned for more details.

    Please help get the results you want in the SQL query

    Kind regards

    Souls

    Hello

    Here's one way:

    WITH got_new_grp AS

    (

    SELECT name, shift_start, shift_end

    CASE

    WHEN shift_start = TRUNC (shift_start)

    AND shift_start = LAG (shift_end) OVER (ORDER BY shift_start)

    THEN 0

    1. OTHER

    END AS new_grp

    OF shift_dt

    )

    got_grp AS

    (

    SELECT name, shift_start, shift_end

    SUM (new_grp) OVER (ORDER BY shift_start) AS grp

    OF got_new_grp

    )

    SELECT MIN (name) DUNGEON (DENSE_RANK FIRST ORDER BY shift_start)

    As a name

    MIN (shift_start) AS shift_start

    MAX (shift_end) AS shift_end

    OF got_grp

    GROUP BY grp

    ORDER BY shift_start

    ;

    Output (from the full sample data):

    NAME SHIFT_START SHIFT_END

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

    01/01/2015 Brian 09:10 01/01/2015 22:10

    Brian 02/01/2015 09:10 01/05/2015 15:20

    Brian 06/01/2015 10:00 01/06/2015 23:20

    Brian 07/01/2015 11:00 10/01/2015 22:00

    Brian 01/02/2015 15:00 02/02/2015 00:00

    Brian 02/02/2015 11:00 02/02/2015 17:00

    Brian 03/02/2015 00:00 03/02/2015 08:00

    Brian 02/05/2015 15:30 06/02/2015 07:30

    Brian 07/02/2015 23:30 10/02/2015 00:30

    I guess that shift_start is unique.

    It's finally a GROUP BY problem: we want to show the first shift_start and the last shfit_end of a group of 1 or more lines.  The tricky part is to identify the groups.  If I understand the problem, line X is grouped with the previous line X-1 if shift_start on the X line is midnight and is equal to shift_end on line X-1.  The above query uses the LAG analytic to see if each line begins a new group or not and the analytic function SUM to see how many groups have already begun (and therefore, which group each line entry belongs.)

    I still don't understand why you 'Corrected name of Anne in Brian' and not vice versa.  I guess the name to display in each group is the name of the first row in the Group (i.e. the line with the shift_start earlier).

  • The highest sum of the values in any 3 consecutive dates.

    Hello

    Given

    create table test (colamt COMP, coldate date);

    Insert test values (10, sysdate + 1);

    Insert test values (20, sysdate-1);

    Insert test values (5, sysdate-5);

    Insert test values (25, sysdate);

    Insert test values (35, sysdate-11);

    Insert test values (10, sysdate + 1);

    Insert test values (1, sysdate-1);

    Insert test values (5, sysdate-2);

    Insert test values (20, sysdate-3);

    Insert test values (10, sysdate-4);

    commit;

    SQL > select * from test by coldate;

    COLAMT COLDATE

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

    35 19 MARCH 15

    5 25 MARCH 15

    10 26 MARCH 15

    20 MARCH 27, 15

    5 MARCH 28, 15

    20 MARCH 29, 15

    1 MARCH 29, 15

    25 MARCH 30, 15

    10 MARCH 31, 15

    10 MARCH 31, 15



    I need to find the highest sum of colamt for the whole period of 3 days.

    In this case, it's 50, for the first 3 lines, 19 to March 26.

    (In the real world, I need to know the amount the highest recovery archived how many bytes were generated for consecutive periods of 3 size my FRA v$ archived_log)

    I'm just a DBA and scratch my head to the analytical functions available for me. : ()

    Hello

    To display the best total of 3 rows and the date range when the total highest has been reached:

    WITH got_total_colamt AS

    (

    SELECT coldate

    SUM (colamt) OVER (ORDER BY coldate

    LINES BETWEEN 2 PRIOR

    AND CURRENT ROW

    ) AS total_colamt

    , LAG (coldate, 2)

    COURSES (ORDER BY coldate

    ) AS start_coldate

    OF the test

    )

    got_rnk AS

    (

    SELECT coldate, total_colamt, start_coldate

    , EVALUATE () OVER (ORDER BY total_colamt DESC) AS rnk

    OF got_total_colamt

    )

    SELECT total_colamt

    start_coldate

    coldate AS end_coldate

    OF got_rnk

    WHERE rnk = 1

    ;

    Output:

    TOTAL_COLAMT START_COLDA END_COLDATE

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

    50 19 March 2015 March 26, 2015

    If you do not need to display the dates, the above query can be shortened a little.

    Etbin showed how to get 3 days in response #1, usinng the analytical SUM function totals.  The analytic RANK function, estimated above, which of the totals is higher (or, in the event of a tie, lines 2 or more have the largest number).  Because you cannot nest analytic functions, the analytical SUM function should be called in a separate subquery before calling the analytic RANK function.  Since the analytical functions are calculated after the WHERE clause has been applied, you cannot use in a WHERE clause. That is why RANK is compuuted in another subquery and its results used in the WHERE clause of the main query.

Maybe you are looking for

  • Simple (?) followed by question!

    I have logical X race on El Capitan. Everything works fine; have my guitar as an analogue of entry and use the Amplitube 4 as a software amp. Problem is, I want to play with my registered and drummer songs in Logic X (a few laps of practice before th

  • Z510 - calibrate the battery

    I have lenovo ideapad z510 i7. I want to calibrate the battery because it's showing the level of remaining battery bad Mod edit: System model added to the front of the subject line to improve visibility / clarity.

  • Are old Firmware - there links?

    OK, so my dad bought a new fuse of 8 GB to replace the one I killed trying to install the update of the firmware (Yes its dead ones, and it was very expensive), but I want to go slowly on the update the firmware because of the fact that it is an Ebay

  • What are hs_err_pid5 and hs_err_pid1? and what do I do?

    When I sigsn, I have now these 2 icons on my desktop.  hs_err_pid5 and hs_err_pid1. What do this mean and what do I do?

  • Renewal will not update

    renewal will not be updated after purchase. Reinstalled and still not working, it's been about 3 weeks.