1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Help suming query fields.

Discussion in 'SQL PL/SQL' started by gammaman, May 2, 2010.

  1. gammaman

    gammaman Guest

    i have this query that produces the first three columns below. I would like to add a fourth column (Not in the database just in a display).
    This fourth column will store a running total of the order Qty of each ordered item for a specific contract.

    Code (Text):

    Contract#      Item#     Order Qty    Running Total
    1001              1008           10                  10
    1001              1008           12                  22
    1002              1008            2                    2
    1002              1008            3                    5

    See the running total column I created, that is what I want to produce. Here is the code that creates the query for the first three columns

    Code (Text):

     $summary = oci_parse($conn,'select "CONTRACTS"."CONTRACTNO" as "CONTRACTNO",
         "MADEOF"."ITEMNUM" as "ITEMNUM",
     from    "ORDERS" "ORDERS",
         "MADEOF" "MADEOF",
     and     "MADEOF"."ORDERNUM"="ORDERS"."ORDERNO"');
  2. zargon

    zargon Community Moderator Forum Guru

    Likes Received:
    Trophy Points:
    Aurora, CO
    You need to use the analytic form of SUM() to generate such a report. An example in the Oracle online documentation is found here:


    at the bottom of the page.