In my SPROC a table named #temp1 contains the following columns:
#temp1 (StoreId, StoreDesc, ReservedQty, AvgPrice, QtyOnHand)
My question is based on the following query
INSERT INTO #temp2 (StoreId, StoreDesc, CommittedQty)
(SELECT StoreId, StoreDesc,
CASE WHEN ReservedQty > QtyOnHand THEN
sum(QtyOnHand * AvgPrice)
ELSE
su...
Hi all,
Let's say I had the following table:
id num_votes total_rating
-------------------------------
1 20 30
2 40 13
3 15 25
I want to join the SUM of all ids, let's say, onto the entire table so it looks like:
id num_votes total_rating sum
----------------------------------...
I have a the query:
SELECT availables.bookdate AS Date, DATEDIFF(now(),availables.updated_at) as Age
FROM availables
INNER JOIN rooms
ON availables.room_id=rooms.id
WHERE availables.bookdate BETWEEN '2009-06-25' AND date_add('2009-06-25', INTERVAL 4 DAY) AND rooms.hostel_id = 5094
GROUP BY availables.bookdate
Which returns something l...
I get this error "Cannot call methods on int" when I try and execute the following sql statement in MVS datasource querybuilder.
SELECT
item_k.ItemID,
item_k.Name AS Expr1,
SUM(item_k.Price) AS TotalPrice
FROM
item_k
INNER JOIN orderitems_k ON item_k.ItemID = orderitems_k.ItemID
GROUP BY
item_k.Name
what seems ...
Hi folks,
I need to change the sum(decode()) expressions that are like
SUM(Decode(vcon.WAGON_TYPE_CODE,'MS',1,0))
to something that counts rows with vcon.WAGON-TYPE-CODE = 'MS' but only when wag.ACI-TAG-NO is distinct.
So if two columns look like this
vcon.WAGON_TYPE_CODE wag.ACI_TAG_NO
MS HI1111
SS ...
Hi,
I have a query that counts the price of all items between two dates. Here is the select statement:
SELECT SUM(Price) AS TotalPrice FROM InventoryWHERE (DateAdded BETWEEN @StartDate AND @EndDate)
You can assume all of the tables have been set up properly.
If I do a select between two dates and there are no items within that date r...
I'm at school and we are doing this java stuff. We use a special library named sum.kern: http://www.mg-werl.de/sum/bjw.zip
I want to use Groovy instead of Java. But I can't get groovy to use this library. If I add the jar in grape and try to import sum.kern and create a sum.kern.Bildschirm it says that it is not able to find it. How to ...
Hi there
I have to sum some arrays(an array of arrays). The structure of my arrays is like this:
Array([id]=>some_id, [name]=>some_name, [value]=>float_value)
I know that I have N arrays as the one before. I need to sum those with the same id.
any idea?
Example:
**
Array
(
[id] => 1
[name] => John00
[value] => 0.9
)
...
My report is as follows:
One table provides financial information with sums at the group footer (Grouping is called "StockTable_Shipped"). The group is controlled by a boolean value (1=shows shipped data, 0 = shows received data)
The second table is a variance report for data that has been shipped (boolean value of 1) and has a sum at ...
I'm trying to calculate the sum of an array of decimal values in PHP, but for some reason it keeps rounding to integers.
for example:
$oldArray = array(0.00,1000.11,988.92,978.22,964.01,953.07,948.82,917.26,902.56,913.21,904.08,898.86,892.79);
$myVar = 0.0;
for($k=1;$k<10;$k++)
{
$myVar += $oldArray[$k];
}
print_r($myVar);
$oldArray ...
I've got this table with an int(11) column and hundreds of millions of rows. When I run a query like
SELECT SUM(myIntColumn) as foo FROM myTable;
the return value does not make sense--it is smaller than the the single largest max value. My values for this column max out somewhere around 500m, and the signed int should be able to ha...
Hi,
I have two different tables, lead and click. I would like to query MySQL to get the sum of the commissions generated by clicks and leads ordered by date.
Lead
id|date|commission
Click
id|date|commission
(Both have other fields, but they aren't important for this question.)
So if I had:
Lead:
1|2009-06-01|400
2|2009-06-01|3...
Crazy question...however, I want the sum of all the rows in a table for a column (without using the group by clause)
Example:
Table = Survey
Columns = Answer1, Answer2, Answer3
1 1 1
4 3 5
3 3 2
I want the sums for each column.
Final results should look like:
Ans...
Hi All
I have two tables, one with all my Branches, and one with all my sales. The sales table also contains a Sales Rep ID, a Branch ID, a month and a year.
I need a query that will return the sum of a specific rep's sales for a year, grouped by branch and month, and the query must return 0 if there has been no sales in a branch for ...
Hi,
I want to combine three tables - date, lead and click - in a query.
The tables looks like this:
date:
|date|
lead:
id|time|commission
click:
id|time|commission
The table date is just storing dates and is used when getting dates with no click or lead.
So if we have the following data in the tables:
date:
2009-06-01
200...
I have a table that looks like this:
posid sales eid
1 20 001
1 20 002
1 30 001
2 30 001
1 30 002
2 30 001
1 30 002
2 20 002
2 10 002
I want to write a query that would give me sum...
I'm sorry if this is really basic, but:
I feel at some point I didn't have this issue, and now I am, so either I was doing something totally different before or my syntax has skipped a step.
I have, for example, a query that I need to return all rows with certain data along with another column that has the total of one of those columns...
Is there a simple and quick way to use sum() with non-integer values?
So I can use it like this:
class Foo(object):
def __init__(self,bar)
self.bar=bar
mylist=[Foo(3),Foo(34),Foo(63),200]
result=sum(mylist) # result should be 300
I tried overriding __add__ and __int__ etc, but I don't have found a solution yet
EDIT:
Th...
Hi,
I am using SQLite3 in my iPhone app to select data from a table (tbresults), do some calculations on the data and display it in my uitableview. The sql command uses the SUM function and my app doesn't seem to like it.
The method where I do the select from the table is below but processing seems to fail at the following line.
if(s...
I have a method which summarizes a collection of decimal values using a method similar to this...
Dim _amountCollection as New List(Of Decimal)
_amountCollection.Add(145.12D)
_amountCollection.Add(11.32D)
_amountCollection.Add(6547.07D)
Dim _totalAmount as Decimal
For Each _individualAmount as Decimal in _amountCollection
_totalAmou...