Search Results

Search found 2210 results on 89 pages for 'sum'.

Page 9/89 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Can't get Sum() working in Northwind example

    - by Vince
    Hi, The following code is generating a runtime error and I have no idea why. from o in Orders group o by o.Employee into employeeOrders select new { employeeOrders.Key.EmployeeID, employeeOrders.Key.FirstName, Orders = from eord in employeeOrders orderby eord.OrderID select new { eord.OrderID, eord.OrderDate, OrderTotal=eord.OrderDetails.Sum (od => od.UnitPrice) } } The error is Member access 'System.Decimal UnitPrice' of 'LINQPad.User.OrderDetails' not legal on type 'LINQPad.User.Orders I've also tried this in VS2010 with a standard drag and drop data context and same thing. Thanks in advance

    Read the article

  • sum of Times in SQL

    - by LIX
    Hello all, I have some records like this: ID Personel_Code Time --- ------------- ------ 1 0011 05:50 3 0011 20:12 4 0012 00:50 I want to have the sum of times for each person. in this example I want to have the result like this : Personel_Code Time ------------- ----- 0011 26:02 0012 00:50 Thank you.

    Read the article

  • How to implement "select sum()" in Grails

    - by xain
    I have a relationship like this: class E { string name hasMany = [me:ME] } class M { float price } class ME { E e M m int quantity } And I'd hate to iterate to achieve this: "obtain the sum of the quantity in ME times the price of the corresponding M for a given E". Any hints on how to implement it using GORM/HQL ? Thanks in advance

    Read the article

  • excel sum if string

    - by user1834348
    I have table similar to this: 102938 bob 038128 Marc 398401 Tom 298421 Jim 102938 Alex 102938 Junior 209381 Rex 398401 Oby I want to make sometthing like =sumif(A:A, 102938,B:B) and to get "bobAlexJunior" as result. But this is not working becouse sum works with numbers not strings. If i go with lookup, it works with strings but finds only first line, not all lines. Do you have an Idea on how to fix this issue? Thanx

    Read the article

  • Smallest sum of graph weight, where each node are connceted (like a network)

    - by Svisstack
    Hello, What algorithm I can use for problem like this: Have a graph positive weighted, i want to know a smallest possible sum of weights where each node are connected (connected like a network, where each node is a eg. network device). In this network each node can be connected with other node by some other other nodes in way. But all nodes from input graph must be in a network. Any one can help me with this?

    Read the article

  • how do i get the sum of the 4th column

    - by every_answer_gets_a_point
    this statement will generate a 4 column table: SELECT shipped.badguy AS badguy, shipped.sdate AS LineDate, 'Delivery' AS Legend, -price*quantity AS amount FROM product JOIN shipped ON (product.id = shipped.product) UNION SELECT receipt.badguy, receipt.rdate,notes, amount FROM how do i get the total sum of the 4th of column of what the above generates?

    Read the article

  • Calculate the sum of a datagrid's rows

    - by chchrist
    I have this datagrid which has columns with a NumericStepper as an itemEditor where the user can change the number of items he wants to buy. How can I calculate the sum of all cells when the user updates datagrid's values? Thanks in advance

    Read the article

  • MYSQL Order By Sum of Columns

    - by djs22
    Hi all, Any idea on how to order the results of a MYSQL query by the sum of two columns rather than by a single column? Select * FROM table ORDER BY (col1+col2) desc I know that won't work., but I hope it conveys what I want to do fairly well. Thanks!

    Read the article

  • script to sum all numbers in a file (linux)

    - by Mark Roberts
    I have a file which contains several thousand numbers, each on it's own line: 34 42 11 6 2 99 ... I'm looking to write a script which will print the sum of all numbers in the file. I've got a solution, but it's not very efficient. (It takes several minutes to run.) I'm looking for a more efficient solution. Any suggestions?

    Read the article

  • Can get Sum() working in Northwind example

    - by Vince
    Hi, The following code is generating a runtime error and I have no idea why. from o in Orders group o by o.Employee into employeeOrders select new { employeeOrders.Key.EmployeeID, employeeOrders.Key.FirstName, Orders = from eord in employeeOrders orderby eord.OrderID select new { eord.OrderID, eord.OrderDate, OrderTotal=eord.OrderDetails.Sum (od => od.UnitPrice) } } The error is Member access 'System.Decimal UnitPrice' of 'LINQPad.User.OrderDetails' not legal on type 'LINQPad.User.Orders Thanks in advance

    Read the article

  • Defining the hash of an object as the sum of hashes of its members

    - by Space_C0wb0y
    I have a class that represents undirected edges in a graph. Every edge has two members vertex1 and vertex2 representing the vertices it connects. The problem is, that an edge can be specified two directions. My idea was now to define the hash of an edge as the sum of the hashes of its vertices. This way, the direction plays no role anymore, the hash would be the same. Are there any pitfalls with that?

    Read the article

  • MySQL: SUM in WHERE clause

    - by checcco
    Hi guys, I've got this table CREATE TABLE `subevents` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(150) DEFAULT NULL, `content` text, `class` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=MyISAM Each row can have a different value in the 'class' field. I'd like to select any number of rows, ordered randomly, as long as the sum of the values in the 'class' field is equal to 100. How could I accomplish it directly in the MySQL query without doing it later in PHP? Thanks everybody!

    Read the article

  • Sum Values in Multidimensional Array

    - by lemonpole
    Hello all. I'm experimenting with arrays in PHP and I am setting up a fake environment where a "team's" record is held in arrays. $t1 = array ( "basicInfo" => array ( "The Sineps", "December 25, 2010", "lemonpole" ), "overallRecord" => array ( 0, 0, 0, 0 ), "overallSeasons" => array ( "season1.cs" => array (0, 0, 0), "season2.cs" => array (0, 0, 0) ), "matches" => array ( "season1.cs" => array ( "week1" => array ("12", "3", "1"), "week2" => array ("8", "8" ,"0"), "week3" => array ("8", "8" ,"0") ), "season2.cs" => array ( "week1" => array ("9", "2", "5"), "week2" => array ("12", "2" ,"2") ) ) ); What I am trying to achieve is to add all the wins, loss, and draws, from each season's week to their respective week. So for example, the sum of all the weeks in $t1["matches"]["season1.cs"] will be added to $t1["overallSeasons"]["season1.cs"]. The result would leave: "overallSeasons" => array ( "season1.cs" => array (28, 19, 1), "season2.cs" => array (21, 4, 7) ), I tried to work this out on my own for the past hour and all I have gotten is a little more knowledge of for-loops and foreach-loops :o... so I think I now have the basics down such as using foreach loops and so on; however, I am still fairly new to this so bear with me! I can get the loop to point to $t1["matches"] key and go through each season but I can't seem to figure out how to add all of the wins, loss, and draw, for each individual week. For now, I'm only looking for answers concerning the overall seasons sum since I can work from there once I figure out how to achieve this. Any help will be much appreciated but please, try and keep it simple for me... or comment the code accordingly please! Thanks!

    Read the article

  • T-SQL Query to Get SUM(COUNT())

    - by Ted
    Hi, I am planning to get a report for a table with following table structure: ID RequestDate ----------------------------- 1 2010/01/01 2 2010/02/14 3 2010/03/20 4 2010/01/07 5 2009/03/31 I want the results as: I D_Count RequestDate Sum ----------------------------------------- 2 2010/01 2 1 2010/02 3 2 2010/03 5 Pls help.

    Read the article

  • how to have the right sum of type Time with sql

    - by kawtousse
    hi , i have 2 fields called Timefrom and TimeUntill the duration is calculated in TimeSpent. The colonne timeFrom is like the followine: 10:00:00 the colonne timeUntill is like the following: 12:00:00 the time spent colonne has the value: 02:00:00. My goal is to calculate the sum of timeSpent. PLease help.

    Read the article

  • sum up value from textfile - bash

    - by user3493435
    I am trying to sum up the values in a textfile try.txt firstNumber,1 secondNumber,2 I tried with this script #!/bin/bash while IFS, read -r -a array; do printf "%s %s\n" "${array[0]} ${array[1]}" for n in "${array[1]}"; do ((total += n)) echo "total =" $total done done < try.txt and I landed up with this output firstNumber 1 total = 1 secondNumber 2 total = 3 expected output firstNumber 1 secondNumber 2 total = 3 Thanks in advance

    Read the article

  • SQL SERVER – Puzzle Involving NULL – Resolve – Error – Operand data type void type is invalid for sum operator

    - by pinaldave
    Today is Monday let us start this week with interesting puzzle. Yesterday I had also posted quick question here: SQL SERVER – T-SQL Scripts to Find Maximum between Two Numbers Run following code: SELECT SUM(data) FROM (SELECT NULL AS DATA) t It will throw following error. Msg 8117, Level 16, State 1, Line 1 Operand data type void type is invalid for sum operator. I can easily fix if I use ISNULL Function as displayed following. SELECT SUM(data) FROM (SELECT ISNULL(NULL,0) AS DATA) t Above script will not throw an error. However, there is one more method how this can be fixed. Can you come up with another method which will not generate error? Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Puzzle, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQLServer, T SQL, Technology

    Read the article

  • Why does Linq to Entity Sum return null when the list is empty?

    - by Hannele
    There are quite a few questions on Stack Overflow about the Linq to Entity / Linq to SQL Sum extension method, about how it returns null when the result set is empty: 1, 2, 3, 4, 5, 6, 7, and many more, as well as a blog post discussing the issue here. Now, I could go a flag these as duplicates, but I feel it is still an inconsistency in the Linq implementation. I am assuming at this point that it is not a bug, but is more or less working as designed. I understand that there are workarounds (for example, casting the field to a nullable type, so you can coalesce with ??), and I also understand that for the underlying SQL, a NULL result is expected for an empty list. But because the result of the Sum extension for nullable types is also not nullable, why would the Linq to SQL / Linq to Entity Sum have been designed to behave this way?

    Read the article

  • Why does Linq to Entity Sum return null when the result set is empty?

    - by Hannele
    There are quite a few questions on Stack Overflow about the Linq to Entity / Linq to SQL Sum extension method, about how it returns null when the result set is empty: 1, 2, 3, 4, 5, 6, 7, and many more, as well as a blog post discussing the issue here. I feel it is an inconsistency in the Linq implementation. I am assuming at this point that it is not a bug, but is more or less working as designed. I understand that there are workarounds (for example, casting the field to a nullable type, so you can coalesce with ??), and I also understand that for the underlying SQL, a NULL result is expected for an empty result set. But because the result of the Sum extension for non-nullable types is also non-nullable, why does the Linq to SQL / Linq to Entity Sum behave this way?

    Read the article

  • Use Linq to SQL to generate sales report

    - by Richard Reddy
    I currently have the following code to generate a sales report over the last 30 days. I'd like to know if it would be possible to use linq to generate this report in one step instead of the rather basic loop I have here. For my requirement, every day needs to return a value to me so if there are no sales for any day then a 0 is returned. Any of the Sum linq examples out there don't explain how it would be possible to include a where filter so I am confused on how to get the total amount per day, or a 0 if no sales, for the last days I pass through. Thanks for your help, Rich //setup date ranges to use DateTime startDate = DateTime.Now.AddDays(-29); DateTime endDate = DateTime.Now.AddDays(1); TimeSpan startTS = new TimeSpan(0, 0, 0); TimeSpan endTS = new TimeSpan(23, 59, 59); using (var dc = new DataContext()) { //get database sales from 29 days ago at midnight to the end of today var salesForDay = dc.Orders.Where(b => b.OrderDateTime > Convert.ToDateTime(startDate.Date + startTS) && b.OrderDateTime <= Convert.ToDateTime(endDate.Date + endTS)); //loop through each day and sum up the total orders, if none then set to 0 while (startDate != endDate) { decimal totalSales = 0m; DateTime startDay = startDate.Date + startTS; DateTime endDay = startDate.Date + endTS; foreach (var sale in salesForDay.Where(b => b.OrderDateTime > startDay && b.OrderDateTime <= endDay)) { totalSales += (decimal)sale.OrderPrice; } Response.Write("From Date: " + startDay + " - To Date: " + endDay + ". Sales: " + String.Format("{0:0.00}", totalSales) + "<br>"); //move to next day startDate = startDate.AddDays(1); } }

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >