How to get the last row and the sum of all columns in a query

Hello

is there a way to get the last record for a column and the sum of all the Archives to another column in the same query.

Best regards

You must set your needs correctly volunteers to help here...

Your data are not good enough to bring you a precise solution. Purpose, you do not have a column, which draws a distinction between the first and the last entry.

The solution becomes easy based on your design.

I introduced a grouping called 'id' column and a time column called 'time_of_insert' (only this way you can say with confidence that you can differentiate between the first and last (also a foolproof solution) - you can possibly use sequence (instead of date but if you say that you can insert two lines at the same time) ((and then likely sequence would be a better choice to differentiate instead of a timestamp field) etc...)

With your sample data, something like this can be done to get the desired results.

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

WITH dataset AS

(SELECT 1 id, 10 used, 8 remain, systimestamp + 1/24 time_of_insert FROM DUAL

UNION ALL

SELECT the 1 id, 1, 7, systimestamp + 2/24 FROM DUAL

UNION ALL

SELECT the id 1, 2, 5, systimestamp + 3/24 FROM DUAL

UNION ALL

SELECT 1 id, 1, 0, systimestamp + 4/24 FROM DUAL

UNION ALL

SELECT 1 id, 0, 0, systimestamp + 5/24 FROM DUAL

UNION ALL

SELECT the 1 id, 1, 4, systimestamp + 6/24 FROM DUAL)

SELECT *.

(SELECT SUM (used) ON sum_all)

FIRST_VALUE (stay)

COURSES (PARTITION BY id ORDER BY time_of_insert DESC)

last_row

Of THE dataset)

WHERE ROWNUM = 1;

Output:

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

SUM_ALL LAST_ROW

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

15                  4

See you soon,.

Manik.

Tags: Database

Similar Questions

  • How to get the value of a column in sql query?

    Hi, anyone knows how to get the value of a column in sql query?

    Here is my code, the value must be 1350079224397 in my PB, but I get 0

    QString query ("SELECT version FROM db_version");

    QVariant result = sda.execute (query);
    QVariantMap versionMap = result.toList () such () .toMap ();
    If (! versionMap.IsEmpty ())
    {
    qDebug()<"Version: "=""><>
    }

    OK, I have the solution

    QString query ("SELECT version as version FROM db_version");

  • How to get the sum of the first row in the previous row?

    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line. Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Hello

    kamranpathan wrote:
    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line.

    If you do not explicitly give a windowing clause, then you get the default windowing clause you indicated.
    If you want another clause of windowing, ionclude in the analytic function call.

    Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Yes. The correct syntax for "Previous rank" is «PREVIOUS 1»

    ...  ROWS BETWEEN  UNBOUNDED PRECEDING
                AND        1          PRECEDING
    

    For more information, search for "Analytic Functions" in the manual of the SQL language:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm#sthref917

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    You will find the answers better faster if you always provide this information whenever you post a question.

    Published by: Frank Kulash, Sep 17, 2011 17:04
    I just saw Etbin responses.
    As usual, Etbin has a good point. If the column that you are basically cannot be NULL, then it is probably easier to subtract the total current line and use the default windowing clause.
    Even if it can be null, you find may be easier to use this approach.

  • 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.

  • Get the sum of all Member of a hierarchy.

    Hello
    I want to get the sum of each Member in a hierarchy.
    The hierarchy is defined in the strdet table:
    create table strdet
    (costcenterms varchar2(20),     // parent
    costcenterdet varchar2(20),    // child
    lev varchar2(1))
    The values for each object/material by costcenter (child) is defined in the details_det table:
    create table details_det
    (costcenterms varchar2(20),
    eppid varchar2(30) ,
    purchcontyear0 number(4,1) )
    Some examples of data:
    insert into strdet values ('1' , '1.1','2')
    /
    insert into strdet values ('1' , '1.2','2')
    /
    insert into strdet values ('1.1' , '1.1.1','3')
    /
    insert into strdet values ('1.1' , '1.1.2','3')
    /
    insert into strdet values ('1.2' , '1.2.1','3')
    /
    insert into strdet values ('1.2' , '1.2.2','3')
    /
    insert into strdet values ('1.2' , '1.2.3','3')
    /
    insert into strdet values ('1.1.1' , '1.1.1.1','4')
    /
    insert into strdet values ('1.1.1' , '1.1.1.2','4')
    /
    insert into strdet values ('1.1.2' , '1.1.2.1','4')
    /
    insert into strdet values ('1.2.1' , '1.2.1.1','4')
    /
    insert into strdet values ('1.2.1' , '1.2.1.2','4')
    /
    COMMIT;
    insert into details_det values('1.1.1.1','epp1',10);
    insert into details_det values('1.1.1.1','epp2',20);
    insert into details_det values('1.1.1.1','epp3',0);
    insert into details_det values('1.1.1.2','epp1',0);
    insert into details_det values('1.1.2.1','epp2',5);
    insert into details_det values('1.1.2.1','epp4',15);
    insert into details_det values('1.2.1.1','epp1',65);
    insert into details_det values('1.2.1.1','epp2',95);
    insert into details_det values('1.2.1.2','epp1',5);
    commit;
    The desired sql stmt output should be like this:
    costcenter             val
    --------------             ------
    1                        220
    1.1                       55
    1.2                     165
    1.1.1                    30
    1.1.2                    20
    1.2.1                  165
    I wrote the following, so far...
    SQL> select distinct s.costcenterms , sum(purchcontyear0) over(partition by s.costcenterms order by s.costcenterms)
      2        from details_det d , strdet s
      3        where s.costcenterdet=d.costcenterms(+)
      4        start with s.costcenterms='1'
      5             connect by  s.costcenterms = prior s.costcenterdet
      6        order by s.costcenterms
      7  /

    COSTCENTERMS                                                 SUM(PURCHCONTYEAR0)OVER(PARTIT
    ------------------------------------------------------------ ------------------------------
    1.2                                                         
    1.2.1                                                                                   165
    1.1.1                                                                                    30
    1.1.2                                                                                    20
    1                                                           
    1.1                                                         

    6 rows selected
    How should I modify the above sql stmt to get the result you want...?

    Note: I use OracleDB 10 g. v.2

    Thank you very much
    SIM

    sgalaxy wrote:
    Anyway, since I want to use the sql stmt to define a materialized view, all versions of data of hierarchical queries are not allowed... (oracle ora-30361 error...).

    No error on my:

    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    
    SQL> create materialized view x_mv
      2  as
      3  select  grp,
      4          sum(purchcontyear0)
      5    from  (
      6           select  connect_by_root s.costcenterms grp,
      7                   d.purchcontyear0
      8             from  strdet s,
      9                   details_det d
     10                   where s.costcenterdet=d.costcenterms(+)
     11                   connect by s.costcenterms = prior s.costcenterdet
     12          )
     13    group by grp
     14  /
    
    Materialized view created.
    
    SQL> select  *
      2    from  x_mv
      3    order by grp
      4  /
    
    GRP                  SUM(PURCHCONTYEAR0)
    -------------------- -------------------
    1                                    215
    1.1                                   50
    1.1.1                                 30
    1.1.2                                 20
    1.2                                  165
    1.2.1                                165
    
    6 rows selected.
    
    SQL> 
    

    SY.

  • try to get the SUM of all of the charges with the having clause

    Hi Oracle users.

    I'm trying to accomplish to get a sum of a series of charges and it should be easy, but I can't get it.

    For example, I have the following.

    Select ACCTLOC,  count(ACCTLOC) AS TOTALP
    FROM BOX_ACCTS_TBL 
     WHERE TIME_REQ > SYSDATE-120
     Group By ACCTLOC
      having (count(ACCTLOC) > 1)
     
     the results are
     
    ACCTLOC   TOTALP
     
    Philly     15970
    NY          8623
    Tacoma        3
    SanFran     195
    Hartford    5
    Miami       4374
    
      
    

    How can I get the SUM of this group? Do I put this in PL SQL and do a procedure to carry out the selection? Is this the way to go on this?
    I appreciate all the comments you can give.

    Thank you!

    with

    query_result as

    (select 'Philly' acctloc, 15970 totalp Union double all the)

    Select "NY", 8623 Union double all the

    Select "Tacoma", 3 double Union all

    Select "SanFran", 195 double Union all

    Select "Hartford", 5 Union double all the

    Select 'Miami', double 4374

    )

    Select acctloc, totalp, sum (totalp) on the_sum, avg (totalp) (on the_avg), ratio_to_report (totalp) (percentages))

    of query_result

    ACCTLOC TOTALP THE_SUM THE_AVG PERCENTAGES
    Philly 15970 29170 4861.66666666666666666666666666666666667 .547480287967089475488515598217346588961
    NY 8623 29170 4861.66666666666666666666666666666666667 .295611930065135413095646211861501542681
    Tacoma 3 29170 4861.66666666666666666666666666666666667 .000102845389098388755570791909496057593
    SanFran 195 29170 4861.66666666666666666666666666666666667 .006684950291395269112101474117243743572
    Hartford 5 29170 4861.66666666666666666666666666666666667 .000171408981830647925951319849160095989
    Miami 4374 29170 4861.66666666666666666666666666666666667 .149948577305450805622214604045251971203

    Concerning

    Etbin

  • How to get the statistics of all the virtual machines that is going down the network packet last week?

    Hello

    I have this script (new) to Mr. LucD grace who 'supposed' to collect the list of any package of network statistics dropped as scheduled:$start = Get-Date ' 01/01/2015 00:00 "

    $finish = Get-Date "21/01/2015 14:30"
    
    $metrics = "net.droppedRx.summation","net.droppedTx.summation"
    foreach($esx in (Get-VMHost)){
        $vms = Get-VM -Location $esx
        if($vms){
            Get-Stat -Entity $vms -Stat $metrics -Start $start -Finish $finish -ErrorAction SilentlyContinue |
            where {$_.Instance -ne ""} |
            Group-Object -Property {$_.Entity.Name,$_.Instance} | %{
                $_.Group | Group-Object -Property Timestamp | %{
                    New-Object PSObject -Property @{
                        VMHost = $esx.Name
                        VM = $_.Group[0].Entity.Name
                        VmNic = $_.Group[0].Instance
                        "Receive Dropped Packets" = $_.Group | where {$_.MetricId -eq "net.droppedRx.summation"} | Select -ExpandProperty Value
                        "Transmit Dropped Packets" = $_.Group | where {$_.MetricId -eq "net.droppedTx.summation"} | Select -ExpandProperty Value
                        Timestamp = $_.Group[0].Timestamp
                        "Interval (seconds)" = $_.Group[0].IntervalSecs
                    }
                }
            }
        }
    } | Export-CSV -path C:\Temp\Result.CSV
    

    but somehow there is no results coming out of this script?

    How can I get the result the. CSV file?

    The ForEach loop do not put anything in the pipeline, but that can be fixed by using the call operator (and)

    $finish = get-Date ' 21/01/2015 14:30 '.

    $metrics = "net.droppedRx.summation", "net.droppedTx.summation".

    & {foreach ($esx in (Get-VMHost)) {}

    $vms = get-VM-location $esx

    {if ($VMS)}

    Get-Stat - $vms - Stat $metrics entity - start $start - finishing $finish - ErrorAction SilentlyContinue |

    where {$_.} {Example - don't ""} |

    Group-object - property {$_.} @entity.name, $_. Instance} | %{

    $_. Group | Group-object - property Timestamp | %{

    New-object PSObject-property @ {}

    VMHost = $esx. Name

    VM = $_. Group [0]. @entity.name

    VmNic = $_. Group [0]. Instance

    "Receive ignored packages" = $_. Group | where {$_.} MetricId - eq "net.droppedRx.summation"} | Select value - ExpandProperty

    "Transmit ignored packages" = $_. Group | where {$_.} MetricId - eq "net.droppedTx.summation"} | Select value - ExpandProperty

    Timestamp = $_. Group [0]. Timestamp

    'Interval (seconds)' = $_. Group [0]. IntervalSecs

    }

    }

    }

    }

    }} | Export-CSV-path C:\Temp\Result.CSV

  • Please, I beg you! Need a c# example on how to get the list of all host ESX via SDK... I can connect... etc...

    Hello

    I am train to figure this out for a few hours now... and all I find is some examples related to the properties of the VM or something else.

    Now I am able to connect to the server and retrieve things like: Server date and time, version of the API etc...

    I would like to get a code example that would give me the list of ESX servers include within a Virtual Center Server... the last thing I used I got something like: If. Content.searchIndex.ToMo & lt; Indexderecherche & gt; (so). FindEntities & lt; HostSystem & gt; (null, null);...

    This well liked not... Maybe it was too easy...; (o)

    And if you also have a quick way to let me know how to retrieve a simple thing as a host network adapter config... as if I want to know if it is a static address or dhcp etc...

    PS. I have created also a ref to the service instance and service content.

    Here's an example to get the version of the API: (I want that same thing as host nic for setting... but have not yet found the correct syntax)

    var test = SERVICE_CONTENT.about.apiVersion.ToString ();

    MessageBox.Show ("test");

    Also... YES, I'm looking at the SDK prog. Guide... but all of the examples in which are in java... and a little far, the syntax is the same as c#

    Jon

    Thank you and I will award points to a significant response...

    consoleVnic is an array of HostVirtualNic. Therefore, you must print a specific item from the array and not the array itself. It seems that this is the problem.

  • How to get the resolution of all screens

    Hello, I am trying to get the screen resolution and the position (display two left or right of a display) all connected screens (normally two) of LabView 8.6. My idea was to take the .net 'system.windows.forms.screen' class, but there is no public constructor.

    Can someone help me?

    Best regards, Nicolas

    Hey,.

    You can use a propertynode on the class of application with the property "Display.AllMontiors".

    Christian

  • How to get the checksum for several columns?

    I need to compare the data of a record in a data table in another table. The structures of the two tables are not the same, but the data types of the columns I'm comparing cam is obviously the same. There are many columns so I thought that a shortcut to make a crazy long A = A AND B = B, etc... several dozens of times to check if the data are different each time was to use checksum.

    I had planned to use the concatenation of all the columns together in a single string, delmitted by a semicolon.

    However, I find that it does not work as desired. The checksum produces the same number for different values of data. So I need ot use something else.

    There is another function I could use in a similar way where it will create a compact, unique hash to a concatenated string of time I spend?

    And what is the data type of the return value - hoping that it's digital!

    What checksum algorithm do you use?

    Depending on the version of Oracle, you can use the HASH of the package DBMS_CRYPTO method, i.e.

    SELECT dbms_crypto.hash( to_clob( ename || empno || sal ),
                           1 /* dbms_crypto.hash_md4 */ )
      FROM emp
    

    A MD4 hash should have a very low incidence of collisions of normal data even if it isn't particularly cryptographically course. You can also use the ORA_HASH method

    SELECT ora_hash( ename || empno || sal )
      FROM emp
    

    but I expect the chance of collisions to be a little higher.

    Justin

  • How to get the master spread all the names and UIDRefs

    I create a document from a template. I have a list of pages to be added to the model, as well as the names of master pages which should apply to the pages.

    Looking through the SDK, it seems to me that BuildMasterSpreadList would give me what I want - an ID user name mapping. But I can work on how to call correctly, because I'm pretty new to the InDesign API.

    The first parameter of BuildMasterSpreadList is IStringListControlData * which must be transmitted to empty and should return a list of names. But I can't find out how to create an empty IStringLIstControlData object, since all the code sample appear to create from a dialog Widget.

    Help with this specific part of my task, or suggestions on how better to approach creation of pages and appointed master pages that are applicable would be much appreciated.

    Hello pdurrant,

    You can use the IMasterSpreadList interface on kDocBoss to iterate over a document master spreads. With the UID of each mask be spread, you can access its IMasterSpread interface.

    Markus

  • How to get the names of all data centers in vSphere

    Hello

    The following code retrieves the path of ful of VMDK files.

    How can I get this info to all the domain controllers in my environment instead of questioning a DC at a time?

    CODE:

    Get-data center $DC | Get-Datastore. Where-Object {$_.} {Name - notlike "DataStore1 *"} |
    Sort-Object-property name.
    Select-Object - property name,
    @{Name = "CapacityGB"; Expression = {[Math]: tour ($_.)} (CapacityGB, 0)}},
    @{Name = "UsedSpaceGB"; Expression = {[Math]: tour ($_.)} CapacityGB-$_. (FreeSpaceGB, 0)}},
    @{Name = "FreeSpaceGB"; Expression = {[Math]: tour ($_.)} (FreeSpaceGB, 0)}},
    @{Name = "UncommittedSpaceGB"; Expression = {}
    If (-not $_.) ExtensionData.Summary.Uncommitted) {}
    0
    }
    else {}
    [Math]: tour ($_.) ExtensionData.Summary.Uncommitted/1GB,0)
    }
    }},
    @{Name = "ProvisionedSpaceGB"; Expression = {}
    $Summary = $_. ExtensionData.Summary
    If (-not of $Summary.Uncommitted) {}
    [Math]: round (($Summary.Capacity-$Summary.FreeSpace)/1GB,0)
    }
    else {}
    [Math]: round (($Summary.Capacity-$Summary.FreeSpace + $Summary.Uncommitted) / 1 GB, 0)
    }
    }},
    @{Name = "PercentageUsed"; Expression = {[Math]: round (100 *($_.)} CapacityGB-$_. FreeSpaceGB) / $_. (CapacityGB, 0)}},
    @{Name = "PercentageFreeSpace"; Expression = {[Math]: round (100 * $_.)} FreeSpaceGB / $_. (CapacityGB, 0)}},
    @{Name = "PercentageProvisioned"; Expression = {}
    $Summary = $_. ExtensionData.Summary
    If (-not of $Summary.Uncommitted) {}
    [Math]: round (100 * ($Summary.Capacity-$Summary.FreeSpace)/$Summary.Capacity,0))
    }
    else {}
    [Math]: round (100 * ($Summary.Capacity - $Summary.FreeSpace + $Summary.Uncommitted)/$Summary.Capacity,0))
    }
    }},
    @{Name = 'MV'; Expression = {[string]: join (';', ($_.))} ExtensionData.Vm | ForEach-Object {Get-View-Id $_}). Name)}}.
    @{Name = "VMDK"; Expression = {[string]: Join (';', (& {}}
    $Datastore = $_
    $Datastore.ExtensionData.Vm |
    {ForEach-Object
    Notice-EEG-Id $_.
    Get-VIObjectByVIView |
    Get-hard drive |
    Where-Object {$_.} FileName-like "* $($Datastore.Name) *"} ".
    }
    }). File name)

    }} | Export-CSV $FileName - NoTypeInformation - UseCulture

    The easiest way is to make equal $DC to ' *'.

  • How to get the total of a column in php

    I have a php MySQL database that stores the bills paid, I need to show all of the column that stores the individual payments

    what I have so far

    $colname_rsProperty = "-1";

    If (isset($_GET['recordID'])) {}

    $colname_rsProperty = $_GET ["recordID"];

    }

    @mysql_select_db ($database_hostprop, $hostprop);

    $query_rsProperty = sprintf ("" SELECT * FROM host_editprop, host_editpropUtil, host_editpropUtilComp WHERE host_editprop.prop_id = AND host_editpropUtil.prop_id = host_editprop.prop_id AND host_editpropUtilComp.utilID = host_editpropUtil.UtilPropNameID %s ", GetSQLValueString ($colname_rsProperty,"text")");

    $query_limit_rsProperty = sprintf ("%s LIMIT %d, %d", $query_rsProperty, $startRow_rsProperty, $maxRows_rsProperty);

    $rsProperty = mysql_query ($query_limit_rsProperty, $hostprop) or die (mysql_error ());

    $total = 0;

    $total += $row_rsProperty ["utilityAmount"];

    the host_editpropUtil column is called utilityAmount

    and the individual amounts are the echoes of

    <? PHP echo DoFormatCurrency ($row_rsProperty ['utilityAmount'], 2, ','.', ' £');? >

    and I want to put the total at the end of these

    and just an echo of the total need

    <? PHP echo $total? >

    This is just to show the first value in the table

    Thanks in advance

    got it to work

    $colname_rsProperty = "-1";

    If (isset($_GET['recordID'])) {}

    $colname_rsProperty = $_GET ["recordID"];

    }

    @mysql_select_db ($database_hostprop, $hostprop);

    $query_rsProperty = sprintf ("" SELECT * FROM host_editprop, host_editpropUtil, host_editpropUtilComp WHERE host_editprop.prop_id = AND host_editpropUtil.prop_id = host_editprop.prop_id AND host_editpropUtilComp.utilID = host_editpropUtil.UtilPropNameID %s ", GetSQLValueString ($colname_rsProperty,"text")");

    $rsProperty = mysql_query ($query_rsProperty, $hostprop) or die (mysql_error ());

    $row_rsProperty = mysql_fetch_assoc ($rsProperty);

    $totalRows_rsProperty = mysql_num_rows ($rsProperty);

    @mysql_select_db ($database_hostprop, $hostprop);

    $query_rsSum = sprintf ("SELECT host_editpropUtil.utilityAmount, host_editprop.prop_id, host_editprop, host_editpropUtil.prop_id FROM host_editpropUtil WHERE host_editpropUtil.prop_id = host_editprop.prop_id AND host_editprop.prop_id = %s", GetSQLValueString ($colname_rsProperty, "text") ");

    $rsSum = mysql_query ($query_rsSum, $hostprop) or die (mysql_error ());

    $totalRows_rsSum = mysql_num_rows ($rsSum);

    $grandTotal = 0;

    Use a loop here

    {If ($row_rsSum = mysql_fetch_assoc ($rsSum))

    $grandTotal += $row_rsSum ["utilityAmount"];

    $row ['utilityAmount'] ;// and view the contents of the line

    $row ['SUM (utilityAmount)'; / / and display the contents of the line

    }

  • How to get the total number of records for this query

    SELECT SSN, FIRST, MID, LAST, UCX_UCFE, TRAPOSS, DUAPOSS, CLAIM_SEQ, CLAIM_DT, MAX (INSERT_DT) INSERT_DT.
    CLAIM_STAT, ISSUE_CDE, AGENT_ID FROM (SELECT A.SSN, A.FIRST A.MID, A.LAST, B.UCX_UCFE, B.TRAPOSS, B.DUAPOSS,
    C.CLAIM_SEQ, C.CLAIM_DT, C.INSERT_DT, C.CLAIM_STAT, C.ISSUE_CDE,
    RN C.AGENT_ID, ROWNUM
    THE APPLICANT HAS, CLMTELIG B, UICLAIMS C
    WHERE A.CLMT_SEQ = B.CLMT_SEQ AND B.CLMT_SEQ = C.CLMT_SEQ AND TRUNC (C.INSERT_DT) BETWEEN 1 JANUARY 09 ' AND 5 JANUARY 09')
    GROUP OF NSS, BEGINNING, MIDDLE, LAST, UCX_UCFE, TRAPOSS, DUAPOSS, CLAIM_SEQ, CLAIM_DT, CLAIM_STAT, ISSUE_CDE, AGENT_ID



    Thank you all in advance for watching in my post.

    Select count (*)
    Of
    (.. .your question here...) ;

  • How to get the sum by customer?

    Hi, in this query below, I want all the s () basically summing up of each "INVESTOR_CODE", can anyone help please?
    select 
    b.INVESTOR_CODE ,
    a.INVESTOR_NAME , 
    b.DEPARTMENT_CODE , 
    b.INVOICE_NO , 
    b.INVOICE_TYPE , 
    trunc(b.INVOICE_date) INVOICE_date, 
    c.COMPANY_SHORT_NAME , 
    sum(INVOICE_COMMISSION)  INVOICE_COMMISSION, 
    sum(INVOICE_KEEPING)  INVOICE_KEEPING , 
    sum(INVOICE_STAMP)  INVOICE_STAMP, 
    sum(INVOICE_OTHER) INVOICE_OTHER,
    sum(INVOICE_MISR) INVOICE_MISR,
    sum(INVOICE_INSURANCE) INVOICE_INSURANCE,
    sum(INVOICE_HAIAH)INVOICE_HAIAH
    from investor a , invoice b , company c , DEPARTMENT d
    where a.INVESTOR_CODE = b.INVESTOR_CODE
    and b.COMPANY_CODE = c.COMPANY_CODE
    and b.DEPARTMENT_CODE  = d.DEPARTMENT_CODE
    and trunc(invoice_date) >= '14-AUG-07'
    exists(select 1 from OPERATION_LINE_SMAEDAY ols where ols.INVOICE_NO  = b.INVOICE_NO and ols.INVOICE_type  = b.INVOICE_type  )
    group by  b.INVESTOR_CODE , a.INVESTOR_NAME , b.DEPARTMENT_CODE , b.INVOICE_NO , b.INVOICE_TYPE , trunc(b.INVOICE_date) , b.INVOICE_TYPE,c.COMPANY_SHORT_NAME
    order by b.INVESTOR_CODE  , INVOICE_date;

    For this table, the following query will do the grouping and order it as you want. You will still combine it with the previous query using the original paintings.

    SQL> select investor_code
      2       , investor_name
      3       , department_code
      4       , invoice_no
      5       , invoice_type
      6       , invoice_date
      7       , company_short_name
      8       , sum(invoice_commission)
      9       , sum(invoice_keeping)
     10       , sum(invoice_stamp)
     11       , sum(invoice_other)
     12       , sum(invoice_misr)
     13       , sum(invoice_insurance)
     14       , sum(invoice_haiah)
     15    from samedaydata
     16   group by investor_code
     17       , investor_name
     18       , rollup
     19         ( ( department_code
     20           , invoice_no
     21           , invoice_type
     22           , invoice_date
     23           , company_short_name
     24           )
     25         )
     26   order by investor_code
     27       , department_code
     28       , invoice_no
     29  /
    
    INVESTOR_CODE INVESTOR_NAME   DEPARTMENT_CODE INVOICE_NO INVOIC INVOICE_DATE        COMPANY_SHORT_NAME   SUM(INVOICE_COMMISSION)
    ------------- --------------- --------------- ---------- ------ ------------------- -------------------- -----------------------
    SUM(INVOICE_KEEPING) SUM(INVOICE_STAMP) SUM(INVOICE_OTHER) SUM(INVOICE_MISR) SUM(INVOICE_INSURANCE) SUM(INVOICE_HAIAH)
    -------------------- ------------------ ------------------ ----------------- ---------------------- ------------------
           240007 john                          2        123 sell   23-04-2010 00:00:00 OTC                                     27.5
                     3.4                  6                  4                 0                      2                 10
    
           240007 john                          2        124 buy    22-04-2010 00:00:00 ORACLE                                  29.6
                     2.4                  6                  4                 0                      2                 10
    
           240007 john                          2        125 sell   01-01-2010 00:00:00 ORACLE                                  63.5
                     2.4                  6                  4                 7                      2                 10
    
           240007 john                                                                                                         120.6
                     8.2                 18                 12                 7                      6                 30
    
           240008 paul                          3        256 sell   19-12-2010 00:00:00 OTC                                     93.5
                     8.4                  6                  4                 0                      2                 10
    
           240008 paul                          3        266 buy    06-03-2010 00:00:00 CBANK                                   83.2
                     3.4                  6                  3                 0                      2                  9
    
           240008 paul                          3        322 buy    23-04-2010 00:00:00 CBANK                                   43.4
                     2.4                  3                  4                 0                      2                  3
    
           240008 paul                          3        423 sell   23-04-2010 00:00:00 OTT                                     24.5
                     2.4                  2                  4                 0                      8                 10
    
           240008 paul                                                                                                         244.6
                    16.6                 17                 15                 0                     14                 32
    
    9 rows selected.
    

    Kind regards
    Rob.

Maybe you are looking for

  • Qosmio G20 - line of dead pixels

    The other night a solid line of dead pixels appeared on the left side of my screen. It just appeared out of nowhere, a yellow solid and thick 1 pixel wide line. Is there something that can be done for this? It can be repaired? I think my computer is

  • HP Compaq 6720 s: Power-on password

    Hello world My hard drive died a few months and when I bought a new, I couldn't do anything on my laptop because of some power on password. So, I google a bit and discovered that it's the BIOS password.I get no error code because I wrote incorrect pa

  • number of items in the queue

    I'm working on an upcoming project that will need to use a loop of producer/consumer structure. Right now, I have added a simple test of how I want the VI to work, but I'm having a problem. When I run the VI, the "elements of # in the queue" increase

  • How can I connect another computer wireless to my counter top?

    Trying to connect to another computer wireless to my desktop for the internet. HOW?

  • I broke my xp pro cd I have proof of ownership in photos

    My 7 year old child stepped on my windows xp pro cd and broke it. I took several pictures with me holding the disc broke and the tag keys and detail that I can send them. I just need a new disk sent to me please, no key toh just full installation dis