Column sum based on a single value of another column

Hi all

I've searched and searched, but just can't find if this is even possible, let alone how to do it.  What I'm trying to do, it's the sum of a column.  However, only summarize the results of this column if a specific value of another column is present.  So, for example, the following is a sample database entry:

Rate of pay hours

2.3                                  $14.00

1.2                                  $14.00

2.4                                  $12.50

0.75                                $12.50

So for that, I want the sum of hours worked column but only the sum of hours worked if the wage rate is $14.00 and $ 12.50.  Because these numbers are generated in a database (with the various people who enter multiple rates of pay), I won't be able to set the where statement to have a specific amount (since I don't know the specific amount each registrant), the amount must be a variable in the where the statement.  With MySQLI, I know not how to make the sum of hours worked, but I do not know how the sum of hours worked if and only if the line corresponds to the unique value in the rate column.

Then have it automatically loop through and total hours worked for other unique values in the column salary rate.  Finally, out all unique values in the column rate in variables so that I can do the following for each game:

$total1 = $total_hours1 * $wage_rate1
$total2 = $total_hours2 * $wage_rate2
$overall_total = $total1 + $total2

where $wage_rate1 = $14.00 and $total_hours1 = 2.3 + 1.2: etc.

Is it still possible?  If so, how?  If possible, can someone please let me know a good reference so I can learn how to be the best way to implement?

Thank you

So with that, I get the correct $final_total printed, but I still get the error, 'notice: Undefined variable: final_total. Why is it not defined, but prints the total exact? How to remove the error?

You get this notice is because you use the assignment combined, operator that is normally used to add a value to a variable and assign the new value to it.

$final_total += $total;

is a shortcut for this:

$final_total = $final_total + $total;

The undefined $final_total is on the right side of the assignment operator. The first time through the loop, you add $total to a non-existent value. Because of the type of PHP juggling, this becomes:

$final_total = 0 + $total;

The next time the loop runs, $final_total has a value, so that you get the view variable not defined only once.

To avoid advice, initialize $final_total to zero before the start of the loop.

$final_total = 0;

While ($row = {$sql-> fetch_array())}

Tags: Dreamweaver

Similar Questions

  • PARTITION OF? Returns an identifier based on the minimum value of another column

    Hi guys

    I want to return the ID column of a line, where 2 other columns = a value set, and a 3rd column has the minimum value corresponding to the other criteria.

    so, indeed:

    with t as (
    select 1 dst_id, 'abc' dst_title, 1 edition_from, 1 media_item from dual 
    union all 
    select 2 dst_id, 'abc' dst_title, 1 edition_from, 2 media_item from dual 
    union all 
    select 3 dst_id, 'abc' dst_title, 2 edition_from, 1 media_item from dual 
    union all 
    select 4 dst_id, 'abc' dst_title, 2 edition_from, 2 media_item from dual 
    union all 
    select 5 dst_id, 'def' dst_title, 1 edition_from, 1 media_item from dual 
    union all 
    select 6 dst_id, 'def' dst_title, 1 edition_from, 2 media_item from dual 
    )
      select dst_id
      from t
      where dst_title = 'abc' 
      and edition_from = 1
      and media_item = minimum value of media item using above where clause
    Return dst_id = 1 because it has the value point minimum media 1 where dst_title = abc and edition_from = 1

    Is this possible in 1 query? I tried using partition and on dst_title, edition_from, but it does not work.

    I am currently using a query sub or 2 queries, but think that there must be a way to do it in a?

    Thank you all

    Scott

    pus

    with t as (
      select 1 dst_id, 'abc' dst_title, 1 edition_from, 1 media_item from dual union all
      select 2 dst_id, 'abc' dst_title, 1 edition_from, 2 media_item from dual union all
      select 3 dst_id, 'abc' dst_title, 2 edition_from, 1 media_item from dual union all
      select 4 dst_id, 'abc' dst_title, 2 edition_from, 2 media_item from dual union all
      select 5 dst_id, 'def' dst_title, 1 edition_from, 1 media_item from dual union all
      select 6 dst_id, 'def' dst_title, 1 edition_from, 2 media_item from dual
    )
    select min(dst_id) keep (dense_rank first order by media_item) as dst_id
    from t
    where dst_title = 'abc'
    and edition_from = 1
    ;
    
  • How to format a single cell based on the value in another cell?

    IM using JDEV 11.1.2.4 and had the following use cases.

    based on a threshold value in a column of my line, I want to show a different value in the color red.

    How to get there?

    Hello

    This could be a possible solution using inlineStyle and a simple logic of EL

    inlineStyle = ' #{rank. " TRESHOLD > 10? "{" color: #990000 ': "color: #000000 '} '.

    ID = "ot1" / >

    Marc

  • You will need to change based on values in another article LOV...

    Hi all

    I got a mudbrick THAT LOV based on a value in another column. Let me explain... Assume that A value in the column is A1 then column B should show A11, A12, A13 and if column A is the value C cloumn B should show C11, C12... etc. The LOV will be static with some pre defined values. So all the LOVs will be defined in the forms. We just need to show based on the value in column A.

    Please suggest.

    Thank you.

    Published by: Amit1cs on April 18, 2013 19:40

    Amit1cs wrote:
    Hi all

    I got a mudbrick THAT LOV based on a value in another column. Let me explain... Assume that A value in the column is A1 then column B should show A11, A12, A13 and if column A is the value C cloumn B should show C11, C12... etc. The LOV will be static with some pre defined values. So all the LOVs will be defined in the forms. We just need to show based on the value in column A.

    Please suggest.

    Hello Amit,
    Up to now, I understand, you can create several record group for a single LOV. before you display the lov just to change or assign the appropriate record group. You can use pre-text-element column B trigger and set the record group to your LOV.

    Hope this helps

    Hamid

  • Derivative of a cell based on the value of another cell's true/false

    Hello

    I try to create a list of digital control and would have put cells highlight according to a corresponding value in another cell.

    For example, I would like cell D2 to white if the cell H2 is FALSE, or if the values of H2 is TRUE, I would D2 to be green. I want this for about 20 lines.

    Any suggestions?

    Hi JCR.

    Conditional highlighting rules depend on comparing the value contained in the cell to be highlighted (D2) with a second value. The second value may be fixed (recorded in the rule) or may be contained in a cell of the second.

    In your scenario, the highlight would be independent of the value in D2.

    There are two ways to accomplish what you want using conditional highlighting, highlighting a third cell whose value depends on the value in H2 and whose pointing out will be seen as highlighting of the D2, OR by providing a third cell whose value can match or does not match the value in D2 , the value of H2.

    Since you want to highlight only a single cell, and not a group of cells, the second method is probably more simple here.

    Each cell in the column I contains the following formula, entered in I2, and filled then down on the rest of the column:

    I2: = IF (H, D, "xxx")

    English: If the cell in this row of column H is set to TRUE (enabled), copy the value in this row of column D to this cell. If not, put "xxx" in this cell.

    'xxx' can be any value that will be ever present in the cells in column D.

    The below table conditional formatting rule is placed in cells D2 - D10. The cell reference is to the cell "this rank" in column I and is different for each cell.

    Kind regards

    Barry

  • Retrieve a single value from a file .lvm

    I have a large batch of files of worksheet whose name is a timestamp. I am writing a program that will get the value of a specific cell (the same cell in each file), coupled with the timestamp and each of them as a pair of coordinates, then save in a master spreadsheet. The goal is to extract a point each of the 700 files I and compile them into a single file.

    However, I've never used Labview to read the files before. I saw some stuff on how to read an entire worksheet in a table, but I was wondering if there was a way to say to Labview to look into a file and extract a single value. I open .lvm in Excel files, so, in my mind, I would be taking, for example, cell D2. Is this feasible? Should I read the entire worksheet in an array and use the index to pick it up on the table? If I do, how I would specify cell J2 as an array index (I have no experience with the berries in Labview either). In addition, if you have any tips on how to record easily 700 pairs of coordinates, that came together in the order, to a single spreadsheet, that is my next task.

    Essentially- I need to extract a single value of a spreadsheet in, ideally, the simplest possible. In addition, pointers on how to save the numbers gathered at each iteration of a while loop to a single worksheet are welcome.

    Thanks in advance for the help!

    FYI I have LabView v8.6

    You can't say LabVIEW to 'out' a specific 'cell' more you can tell Notepad to do. the .lvm files are just text files. When you open them in Excel, the column separator (default tabs) show to put the values in columns. In LabVIEW measurement file VI reading to read .lvm files. It creates the dynamic data, wrong data type that is next to useless. You will need to convert this type of data in a table by using the function convert of DDT. Or, you can use the VI read spreadsheet file. This will give you a table directly. You can just remove the specific item using the table to Index.

  • based on the prompt value see the FDF anayasis

    Hello

    I have a situation like this
    I use obiee 11g

    Based on the prompt value in him would like to show 3 different analayses.
    I mean that if the value of guest in the page has as abc data it should show the anlaysis1
    If the prompt value data as def it should show the anlaysis2
    If the prompt value data as the IGS, it should show the anlaysis3
    If the prompt value data as jkl it should show the anlaysis3

    Why 3 diff analysis is because I have my list 2 columns in each anayaiss and they are 3 different tables.

    One more thing

    Obiee do we have a show and a return value for a radiobutton/drop-down list. As show us abc how invites and returns 1. is possible?

    Thank you

    Published by: user123 on July 12, 2011 12:29

    You can have n number of reports, simply use the union all in the dash prompt sql results and this will give you the choice to select any report you want.

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • void / vi based on the Boolean value

    Hello

    I have a main vi and I want to call a subvi based on a Boolean value, that is when the Boolean entry gets the true value, the sub - vi must run, otherwise it shouldn't.

    To do this, I added the Boolean control component connector of the sub - vi and I added a while loop in the sub - vi, which has 'continue if true' condition. I also made this point prescribed to the subvi.

    However, I noticed that even if the Boolean value false maintains execution of the sub - vi.

    Can you get it someone please let me know what the problem with this approach?

    Thank you

    Despres

    Put the Subvi code (or the Subvi set) inside the true case of a case structure and wire your boolean to that.  I prefer the second option.

  • How to write a single value in an excel spreadsheet

    Hello

    I use an excel spreadsheet, as if it were an external code module. He does a lot of calculations, all I do is write an individual value, let calculate what it should only then read a return value from this.

    I already have a structure able to read a table, but could someone help me with a piece of code that could write a single value?

    (To read a value unique too may be practical)

    Also, I have the new LabVIEW 2009, so while a fancy to drop some code here as one. PNG, it would be nice to see if this new feature works!

    Thank you, Alec

    Try this. There are 2 point methos (get) and point (put) to read and write the value respectively to a cell in excel.

    Good luck

  • Formula member to sum based on a model

    Hello

    I have a question by creating a formula for a sum based on a model member.

    In a cube, OSI, we have 2 sparse dimensions, which contains a hierarchy of alternative with shared members. There is a hierarchy of high maintenance new shared members are added each month.

    I would like to remove this successor to the shared members hierarchy and replace it with a formula of Member.  This hierarchy looks like this

    Entity CC01 Summation

    CC-01-100

    CC-01-101

    CC-01-111

    etc.

    I tried to add a member formula that corresponds to this model @MATCH ('Entity', ' CC-01 * ") and summarizes all CC - 01 *.  My formula looks like this @SUM (@MATCH ('Entity', ' CC-01 * ")).  It does not work.  She added a few other totals which I have not yet studied.

    Any idea is appreciated...

    Thank you.

    Hello

    It is not necessary to take the name of the dimension of the mbrname. @MATCH (mbrName | genName | levName, 'boss')

    Take the parent where the search should begin here. So, without other hierarchies.

    It should work.

    Kind regards

    Philip Hulsebosch

  • Status/progress bar based on a field value

    Friends, I have a field in a form called 'STATE '. This status has values such as Open project, submitted for approval, approved, completed, closed.    Based on the current value of the situation, I wanted to show a status/progress bar just below the navigation bar that displays the current status.

    Can anyone help?

    George

    Hello

    You can use the built in the 'List of horizontal progression Assistant' list template and create a list with your values, then create a region for this list where you want.

    Thank you

    Mohannad

  • How to select a pixel, or the value of the pixels based on a RGB value, or a range of values?

    Can Photoshop select a pixel, or a set of pixels based on a RGB value? For example, select all the pixels that are 5,6,5 or all pixels that are 238-248, 238-248, 238-248

    Yes.

    Select the ranges of colors in Photoshop

  • ERROR: The specified parameter 'Rental' expects a single value, but your name criteria "PROD" corresponds to multiple values.

    Hello

    I am writing a script to create the new VM (base clone of a virtual machine) in a specific folder.

    When you run the script, I get an error:

    The specified parameter 'Rental' expects a single value, but your name criteria "PROD" corresponds to multiple values.

    Some research led me to a post of 2011, which describes the same error. The only thing is, I can find no trace of open connection and then a more...

    What I tried:

    I run the script on the server for vSphere, so I closed the open vSphere client.

    closing ('disconnect-viserver") all existing connections in the first line of the script-> an error because no connection is open.

    In several places in the script, add the following lines:

    ECHO ' - '.

    $DefaultVIServers <-as noted in the post of 2011

    ECHO ' - '.

    This shows that no connection is open until I do the "connect-viserver", subsequently, apparently, that a connection is established.

    the results and the (current) script are found in the files to attach.

    I also found an error on the "set-PowerCLIConfiguration that I can't explain.

    One last question... Is there a possibility to have the new virtual machine created through 3 hosts? the first on the first host, the second on the second, the third on the third, the fourth back on the first host,... and so on?

    Any help would be appreciated.

    Thank you.

    Johan

    Of course, you can provide the full path, for example see my post of folder by Path .

  • travel-vmhost error - the destination of the specified parameter expects a single value

    I run in an error using Move-VMHost under PowerCLI version 5.5 R2 Patch 1 and 5.8 Release 1.

    There are 6 clusters in the data center.  To the host of the virtual machine between 5 of the clusters that I can run successfully:

    Get-VMHost vmhostname | Moving-VMHost Destination 'NOMCLUSTER '.

    But one group in particular always fails when it is specified as destination of the error message:

    The specified parameter "Desintation" expects a single value, but your criteria of name "cluster6" corresponds to multiple values.

    The only way I can get this working is to do:

    Get-VMHost vmhostname | -Move Destination VMHost (get-cluster | where {$_.name - eq "cluster6"})

    How 'cluster6' could correspond to several cluster names?  Is this just a bug in PowerCLI?  I started using PowerCLI more recently and noticed that some cmdlets can be a bit odd (for example had a few other problems with Get-VMHostStorage and found others have had similar problems with it).  I use this process of moving part of a more automated deployment script.  Prefer to make it as efficient as possible without having to insert the extra if possible Get-Cluster command.

    The Destination parameter on the Move-VMHost cmdlet accepts any VIContainer, not only the clusters.

    I suspect it could VIContainer one another with the same name.

    What this does?

    Get-inventory-name 'cluster6 '.

Maybe you are looking for