How to make a SUM function on table with TI-auto

Hi all
I created a table with column 2:
      CREATE TABLE Suppliers
      (
          Id                     NUMBER(10)              PRIMARY KEY,
          ProductNum       NUMBER(10)              NOT NULL,
          Amount             NUMBER(10)              NOT NULL
     );
Example: I have these data in the table
----------------------------------
Id|ProductNum|Amount|
----------------------------------
1|      4A        |    50   |
----------------------------------
2|      10Q      |     3    |
---------------------------------
1|      4A        |    40   |
---------------------------------
3|      Q9       |     32  |
---------------------------------
2|      10Q      |     60 |
.          .                .
.          .                .
.          .                .
And I want a query to get the sum of the amount of each product, that is if I run this query o the previous table, I expect the following result
------------------------------
ProductNum|Amount|
------------------------------
4A            |     90    |
10Q          |      63   |
Q9            |      32   |
.               |       .    |
.               |        .   |
Thanks in advance

Something like this->

select ProductNum, sum(Amount)
from Suppliers
group by ProductNum;

Kind regards.

LOULOU.

Tags: Database

Similar Questions

  • How to make the column in the table with the formula

    Hi all..
    This is my class
    public class MyNumber{
         private int num;
    
         public int getNum(){
              return num;
         }
    
         public void setNum( int num){
              this.num = num;
         }
    }
    Consider that designing a table with FXML Editor (Builder scene in this case)
    and here are some of my codes
    private TableView tab;
    private TableColumn<MyNumber, Integer> tabColInput;
    private TableColumn tabColOutput;
    
    tab.setEditable(true);
    tabColInput.setEditable(true);
    
    tabColInput.setCellValueFactory( new PropertyValueFactory<Person,Integer>("num") );
    tabColInput.setCellFactory(TextFieldTableCell.forTableColumn());
    tabColInput.setOnEditCommit(
        new EventHandler<CellEditEvent<MyNumber, Integer>>() {
            @Override
            public void handle(CellEditEvent<MyNumber, Integer> t) {
                ((MyNumber) t.getTableView().getItems().get(
                    t.getTablePosition().getRow())
                    ).setNum(t.getNewValue());
            }
        }
    );
    Problem:
    I want to tabColOutput to always show the result for tabColInput multiplied by 2

    for example:
    When I change a line in tabColInput 10, tabColOutput shows 20
    When I change a line in tabColInput to 3, tabColOutput show 6

    Could someone advice me how do?

    PS: I'm not native English, so I'm sorry if I tell it fake ^^

    You're up-to-date data are probably not ObservableValues as properties, so the TableView cannot update dynamically as modification of data items.

  • How to make 2 columns in the table with a long row of data Tyube

    Hello world

    I want to do in my column of table 2 with data Tyube long raw

    How this


    Thank you very much

    I don't think it's possible, use BLOB.

  • How to make a hollow functions var?

    Can someone explain how to make a hollow functions var?

    Daniel

    Do you mean something like this?

    var itemsearchcount = null;
    
    previewdata();
    nextviewdata();
    
    function previewdata(){
        // do something
        itemsearchcount = 1;
        return itemsearchcount;
        };
    function nextviewdata(){
        // do something more
        alert(itemsearchcount);
        };
    
  • How to make the button to set the properties of auto-scale one of the Axes on the graphical indicator so I can turn on or off when I press on it. In the Labview web UI designer

    How to make the button to set the properties of auto-scale one of the Axes on the graphical indicator so I can turn on or off when I press on it.

    I need to change the adjustment vaguely Autoscale property for my graphic indicator. Can someone help me please.

    Thank you!

    Hello

    I have confirmed that there is currently no way programmatically enable/disable autoscaling for axes on the LabVIEW graphical indicator generator of the user Web interface. We noted this to possibly be implemented in the future; Sorry for the inconvenience.

  • How to get the title of a table with FDK?

    How to get the title of a table with ad FDK C++?

    I did people. I get objects table paragraph and later the textual elements for each of them.

  • How to select all text in a table with a single click cell?

    How to select all text in a table with a single click cell? I use TextField.selectAll () when you implement a table cell factory. But when I select a line with a single click, then a click on a table cell again: see the result image

    The text in the table cell is not all selected. What I simply selects all the text in a table cell when there is a click on it. How to realize that? Thank you

    Thanks for help ~.

  • Hello, I would like to know how to make horizontal sites and it moves with scrolling

    Hello, I would like to know how to make horizontal sites and it moves with scrolling

    The scrolling would work with the scrolling of the mouse.

    Site that you mentioned also uses the same movement of scrolling with the horizontal length long.

    This video could give the exact idea:

    https://www.YouTube.com/watch?v=x5YMbB1jMdY

    Thank you

    Sanjit

  • How the values to insert into the table with the command insertion

    Dear all
    can someone tell me how the values to insert into the table with the command insert, I want to say I always use command insert behind my forms on what shutter release button press the button of my save, but today I had a form of 6i, where controls (textbox, combo, etc.) are delineated with directly the table with I guess than the Properties Windows , I created 3 columns in tand 3 text on forms fields, now kindly tell me how to do this fields to fill and do not insert command, I mean directly defined with table column



    Please help me its urgent

    Hello

    If the block is based on your database table, just committed the shape, then changes will be applied to the database.

    François

  • Beginner problems - how to make the sum of the lists in a drop-down table

    Hello

    Please forgive my newness but I'm creating a table with 10 + lines and columns and need to calculate the sum of the columns. The user must select a number from a drop-down list and I would like to summarize these nbumbers at the bottom of the column, seems simple enough...

    I have named each cell in the links tab but can't seem to find the script of the sum on the right. I just started using livecycle and have had a good experience so far.

    I wish it was like excel where you just need to click or highlight the cells you want to summarize and do with it but I can't seem to find the easy button...

    You can not simply highlight a column, name it and then use that name in a script to sum?

    Thanks a lot for all the help and I have looked around, but can't get a grip on this one, so I apologize if this is requested before.

    Go easy on me.

    You have to be very accurate with referencing the fields or the formulas will not work. If you have renamed the fields of their default values, then you should reference them as you named the.

    Here's an example of my hierarchy, called as you explained:

    In this case, the use of scripts on the Total field will look like this:

    this.rawValue = (Row1.A1.rawValue * 1) + (Row2.B1.rawValue * 1) + (Row3.C1.rawValue * 1) + (Row4.D1.rawValue * 1);

    So that when I switch to preview, it behaves correctly:

  • How to make a sum of text_field or column with where condition?

    Hi all

    In Oracle forms 6i, I created a form in which there are 5 text_Items (with 20 none of the displayed fields) namely ACCOUNT FD DO, AMOUNT, INTEREST RATE, STATUS and INTEREST_YEAR.

    FD ACCOUNT NO.

    AMOUNT

    INTEREST RATE

    STATUS

    INTEREST_YEAR

    47665

    50000

    1. 11.5

    E

    5750

    37463

    60000

    12

    D

    7200

    47651

    100000

    1. 12.5

    D

    12500

    34766

    70000

    11

    E

    7700

    I want to make the sum of the INTEREST_YEAR where status = 'E '.

    I created a TOTAL_INTEREST_YEAR name field in which I want to display the sum.

    How the sum with where condition?

    Thank you.

    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

    Oracle form Builder 6i.

    Michael,

    When you write the formula for a calculated item, it does not use PL/SQL expressions (to include built-in DECODING) in Forms 6i.  If there was no conditional control over your calculation, you can simply make your article a summary point and perform the summation over column interest_rate .  However, because your calculation depends on the value in the STATUS column, you will need to use a combination of a calculated item and a summary article because you can't use an IF, DECODE or any other PL/SQL statement in the formula for the calculated item.  Therefore, you need to create a function in the knot of program units and call the function in your formula.  I tested it using the following code and it worked correctly.

    First, create the following function in the node of the object browser program units.

    FUNCTION calc_interest RETURN NUMBER IS
         n_ret_val  NUMBER := 0;
     BEGIN
       IF ( :YOUR_BLOCK.STATUS = 'E' ) THEN
           n_ret_val := :YOUR_BLOCK.interest_rate;
       END IF;
       RETURN n_ret_val;
    END calc_interest;
    

    First, you must change the property to BLOCK request all archives = Yes

    Then, open the palette of your calculated item property, and set the following properties:

    1. calculation = Formula

    2 property Forumla = CALC_INTEREST

    3. point data base = No.

    Now create a second item in the table not based on in your block that will display the amount of the interests summarized.  Open the palette property for this element and set the following properties:

    1 Data Type = number

    2 calculation Mode = Summary

    3. function = sum

    4 summarizes point = "name of your element calculated.

    5 base of data point = No.

    6 canvas = "your canvas.

    When you query your block, you should see the sum of all records where STATUS = 'E '.

    It worked for me, in my example form that I created so this should work for you.

    Craig...

  • How to make a sum of a subquery which first determine the time period and then the total sum.

    Hello

    I know how to solve it in two of the query, but I want to merge this in a single query.

    I have records in a table with the status 1. I also have records in the table with the State 2 and 3. But the 2 and 3 folders can have a period different kind of these must be determined in advance when this is, mind a deviding through 3 or 12 months.

    Double nesting is not allowed with Oracle, I detected. There may be more than 1 card whose status is 2 or 3 and I want to collect these and return as a sum value.

    select clk.clickid
          ,clk.uidclickstatus
          ,clk.period
          ,clk.STARTTIME
          ,clk.stoptime
          ,clk.CREATETIME
          ,clk.VOLUME "Open click volume"
          ,sum(tot_volume) --This doesn't work and is my problem!
          ,(select case
                     when ec.period = 'M' then
                        ec.volume
                     when ec.period = 'Q' then
                        ec.volume / 3
                     when ec.period = 'Y' then
                        ec.volume / 12
                     else
                        0
                   end as tot_volume
            from click ec
            where ec.uidcontract    = clk.uidcontract --807430
              and ec.starttime      = clk.starttime --Maybe the good reader will be saying why are you deviding, this is now directly related to keep it simple for now
              and ec.stoptime       = clk.stoptime --Maybe the good reader will be saying why are you deviding, this is now directly related to keep it simple for now
              and ec.uidclickstatus in (2, 3)
           ) sourced_volume
    from click clk
        ,lscmcontract ctr
    where clk.UIDCONTRACT       = ctr.UIDCONTRACT
      and ctr.UIDCONTRACT       = 807430
      and clk.uidclickstatus    = 1
    order by clk.uidclickstatus asc, clk.period, clk.starttime
    ;
    

    Can someone help me how to solve this problem?

    I'm not a guru on SQL. Straight motion is not a problem but what advanced...

    Thank you

    Nico

    OK, I've already said I'm not a guru, but I solved my problem. I didn't know that it is possible to put a sum around a case. In the end, it is the solution:

    select field
    ,field
    ,(select sum(case
                      when clk.period = 'M' and ec.period = 'M' Then
                            (ec.volume)
                      when clk.period = 'M' and ec.period = 'Q' Then
                            (ec.volume / 3)
                      when clk.period = 'M' and ec.period = 'Y' Then
                            (ec.volume / 12)
                      when ((clk.period = 'Q' and ec.period = 'M') or (clk.period = 'Q' and ec.period = 'Q')) Then
                            (ec.volume)
                      when clk.period = 'Q' and ec.period = 'Y' Then
                            (ec.volume / 4)
                      when clk.period = 'Y' Then
                            ec.volume
                      end) as Month_Vol
    from ec.table
    where ...
      and ...
    ) volume
    from clk.talble
    where ...
    

    Nico

  • How to make the sum of the time through SQL?

    Dear friends

    I have a sh_detail table and there are three fields hours1, hours2 hours3. all fields are of type varchar2.

    data are like

    hours1 hours2 total hours3

    02:45 00:18 01:25

    00:38 01:45 00:00

    02:15 02:00 00:15

    1. I want to add on three fields in the total column

    2 and want to make the sum of all areas as select sum (hours1) of sh_detail.

    Please help I will be grateful.

    Kind regards.

    As others have said, use the NUMBER to store times, or the type of data correct INTERVAL, even if the latter cannot be aggregated (using the SUM).

    In the meantime, this will give you the output desired in a few minutes (it is trivial to convert it back in format hh: mm if you wish):

    SQL> with sample_data (id, hours1, hours2, hours3) as (
      2    select 1, '02:45', '00:18', '01:25' from dual union all
      3    select 2, '00:38', '01:45', '00:00' from dual union all
      4    select 3, '02:15', '02:00', '00:15' from dual
      5  )
      6  select id
      7       , sum(h1) h1
      8       , sum(h2) h2
      9       , sum(h3) h3
     10       , sum(h1+h2+h3) as total
     11  from (
     12  select id
     13       , to_number(substr(hours1, 1, 2))*60 + to_number(substr(hours1, 4, 2)) as h1
     14       , to_number(substr(hours2, 1, 2))*60 + to_number(substr(hours2, 4, 2)) as h2
     15       , to_number(substr(hours3, 1, 2))*60 + to_number(substr(hours3, 4, 2)) as h3
     16  from sample_data
     17  )
     18  group by rollup(id) ;
    
            ID         H1         H2         H3      TOTAL
    ---------- ---------- ---------- ---------- ----------
             1        165         18         85        268
             2         38        105          0        143
             3        135        120         15        270
                      338        243        100        681
    
  • How to make a components functions or eventhandlers visible from the outside

    Afternoon,

    I created a custom component with some public functions called function1, function2 function3 (no real names) my question is I am willing to do the below

    < custom: Com1 height = "100%" width = "100%" function1 = "{this.someFunction}" / > "

    problem is that the function1 is not visible outside Com1,

    My second question is how do I mark my functions as events, so when you look at intellisense they lightning rather than methods I think that the two are closely linked.

    few things are more my code for all my components is separated from my mxml via setting one actionscript actionscript for the parent class, and the class extends hbox or application. hope this makes sense, I am a vb developer not an actionscripter, which is probably why I'm doing something obviously wrong...

    Thanks in advance for any help

    See you soon

    Tom.

    1. you must tell you all that this component has events

    [Event (name = "showPreview", type = "flash.events.Event")]

    2 dispatches the event when it comes

    private void clickHandler(event:MouseEvent):void

    {

    var eventObject:Event = new Event ("showPreview");

    dispatchEvent (eventObject);

    }

    3 listen to the event from outside the component

    customComponent:Component showPreview = "showPreviewHandler (event)" / > "

    4 handle the event.

    private void showPreviewHandler(event:Event):void

    {

    }

  • How to make a sum of working capital for a 12 month calendar look back?

    I have a table with dates and values for each date. I would like to create a total working capital which looks backward from today and give me a total for the past 12/24 months. Is there a feature that will allow me to do this? Thank you!

    Hello

    You could do something like that.

    Version A: = SUMIFS (B, $A, "> =" & EOMONTH(A1,0) (TODAY (), −12) will GET)

    Version b: = SUMIFS (B, $A, "> =" & EOMONTH(A1,0) will GET (TODAY (), 13))

    Version C: = SUMIFS (B, $A, "> =" & EOMONTH(A1,0) will GET (today (), 13) ', ')<>

    A version assumes that you do not want to include values for the current month (part-time).

    Version B "was one more month" so you include the current month.

    Version C would be appropriate if you have future dates in your column too and must exclude those.

    To come back two years you would have-24 or - 25 in formulas.

    More on today, SUMIFS and EOMONTH(A1,0) will GET here, here and here.

    My 39:41 lines are defined as lines of footer to make it easy to enter formulas.  Formulas, of course, could be in a separate table.

    SG

Maybe you are looking for