  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # How to sum order cost  » sql » How to sum order cost

By : user2952973
Date : November 19 2020, 03:59 PM
wish help you to fix your issue I have a problem to show the total sales amount (in other words, sum the Price) for customers total orders. With the following SQL statement, I manage to join the tables 'Order1', 'Order2' and 'Customers' to reach the necessary attributes to show the correct city for customers who have made at least 3 orders and to sum the order quantity to this: , You just have to JOIN of Products table in your query
Try this: code :
``````SELECT c.CityName, SUM(o2.quantity * p.Price) AS 'TotalSalesAmount'
FROM (SELECT DISTINCT Ordernr, CustomerNr FROM Order1) AS o1
INNER JOIN (SELECT o1.CustomerNr
FROM Order1 o1
GROUP BY o1.CustomerNr
HAVING COUNT(o1.CustomerNr) >= 3
) AS a ON o1.CustomerNr = a.CustomerNr
INNER JOIN Order2 o2 ON o1.Ordernr = o2.Ordernr
INNER JOIN Customers c ON o1.CustomerNr = c.CustomerNr
INNER JOIN Products P ON o2.ProductNr = P.ProductNr
GROUP BY c.CityName;
`````` ## minimum cost path through a cost matrix with positive and negative cost

By : Inez Jester
Date : March 29 2020, 07:55 AM
hope this fix your issue Let's say that H[i, j] is the minimum health the player needs when starting from square (i, j). We are interested in H[1, 1], which is the minimum health needed from the starting square.
I assume that all values in the cost matrix M are integers. Therefore, the smallest positive health is 1.
code :
``````H[m, n] = max(1 - M[m, n], 1)
``````
``````H[m, i] = max(H[m, i+1] - M[m, i], 1)
H[j, n] = max(H[j+1, n] - M[j, n], 1)
``````
``````H[i, j] = min(max(H[i, j+1] - M[i, j], 1),
max(H[i+1, j] - M[i, j], 1))
``````
``````int[] H = new int[m, n];

H[m, n] = max(1 - M[m, n], 1);

// remember to loop backwards
for (int i = m-1; i >= 1; i--)
H[m, i] = max(H[m, i+1] - M[m, i], 1);
for (int j = n-1; j >= 1; j--)
H[j, n] = max(H[j+1, n] - M[j, n], 1);

// again, loop backwards
for (int i = m-1; i >= 1; i--)
for (int j = n-1; j >= 1; j--)
H[i, j] = min(max(H[i, j+1] - M[i, j], 1),
max(H[i+1, j] - M[i, j], 1));

return H[1, 1];
`````` ## Calculating cost of an order using PHP

By : Eeshan Kulkarni
Date : March 29 2020, 07:55 AM
wish helps you Here's what I came up with for you. I think it's easier to just write this one out.
Using numerous PHP functions such as:
code :
``````<!DOCTYPE html>
<html>
<title>Lightbulb sales</title>
<body>

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

\$name = \$_POST['name'];
\$location = \$_POST['location'];

/* ====================== ITEMS ====================== */

/* fourLight */
if(isset(\$_POST['fourLight'])  && !empty(\$_POST['fourLight']) && is_numeric(\$_POST['fourLight']) ){

\$fourLight = \$_POST['fourLight'];
\$fourLight_price = "2.39";
\$total_fourLight = \$fourLight * \$fourLight_price;

echo "Four light: \$" . number_format(\$total_fourLight,2);
echo "<br>";

}
else{ \$total_fourLight = 0; }

/* eightLight */
if(isset(\$_POST['eightLight'])  && !empty(\$_POST['eightLight']) && is_numeric(\$_POST['eightLight']) ){

\$eightLight = \$_POST['eightLight'];
\$eightLight_price = "4.29";
\$total_eightLight = \$eightLight * \$eightLight_price;

echo "Eight Light: \$" . number_format(\$total_eightLight,2);
echo "<br>";

}

else{ \$total_eightLight = 0; }

/* fourLong */
if(isset(\$_POST['fourLong']) && !empty(\$_POST['fourLong']) && is_numeric(\$_POST['fourLong']) ){

\$fourLong = \$_POST['fourLong'];
\$fourLong_price = "3.95";
\$total_fourLong = \$fourLong * \$fourLong_price;

echo "Four Long: \$" . number_format(\$total_fourLong,2);
echo "<br>";

}

else{ \$total_fourLong = 0; }

/* eightLong */
if(isset(\$_POST['eightLong'])  && !empty(\$_POST['eightLong']) && is_numeric(\$_POST['eightLong']) ){

\$eightLong = \$_POST['eightLong'];
\$eightLong_price = "7.49";
\$total_eightLong = \$eightLong * \$eightLong_price;

echo "Eight Long: \$" . number_format(\$total_eightLong,2);
echo "<br>";

}

else{ \$total_eightLong = 0; }

/* ====================== TALLY ====================== */

\$sub_total = \$total_fourLight + \$total_eightLight + \$total_fourLong + \$total_eightLong;

\$grand_total_items = number_format(\$sub_total, 2);

echo "<hr>";
echo "Sub-total: \$" . \$grand_total_items;
echo "<br>";

\$tax= 1.08; // tax is calculated this way, not just .08

\$grand_total = \$grand_total_items * \$tax;

echo "Grand total including 8% tax: \$" . number_format(\$grand_total,2);

echo "<br>";

\$checkout = "Checkout text here.";

// Not sure what you want to do with this
function computeCost(){

}

/* ====================== PRINT OTHER ====================== */

print "Name: " . \$name . "<br>";
print "Place: " . \$location . "<br>";

print "<hr>";
print \$checkout . "<br>";
?>
</body>
</html>
``````
``````<!DOCTYPE html PUBLIC "-//w3c//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml-strict.dtd">
<html>
<title>Light bulb Sales</title>
<body>
<form action="light.php" method="post">
<h2>Welcome to Light of your Life Light bulb Sales</h2>
<table>
<tr>
<td><input type="text" name="name" size="30" /></td>
</tr>
<tr>
</tr>
<tr>
<td>City, State, Zip:</td>
<td><input type="text" name="location" size="30" /></td>
</tr>
</table>

<table border="4">
<tr>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<tr>
<td>100-watt Light Bulbs (4)</td>
<td>\$2.39</td>
<td align="center">

<select size="1" name="fourLight">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>

<!-- commented out input -->
<!--
<input type="text" name="fourLight_other" size="3" />
-->

</td>
</tr>
<tr>
<td>100-watt Light Bulbs (8)</td>
<td>\$4.29</td>
<td align="center">

<select size="1" name="eightLight">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>

<!-- commented out input -->
<!--
<input type="text" name="eightLight_other" size="3" />
-->

</td>
</tr>
<tr>
<td>100-watt long-lie Light Bulbs (4)</td>
<td>\$3.95</td>
<td align="center">

<select size="1" name="fourLong">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>

<!-- commented out input -->
<!--
<input type="text" name="fourLong_other" size="3" />
-->

</td>
</tr>
<tr>
<td>100-watt long-lie Light Bulbs (8)</td>
<td>\$7.49</td>
<td align="center">

<select size="1" name="eightLong">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>

<!-- commented out input -->
<!--
<input type="text" name="eightLong_other" size="3" />
-->

</td>
</tr>
</table>

<input type="submit" value="Submit Order" />
<input type="reset" value="Clear order Form" />
</form>
</body>
</html>
``````
``````<select name="fourLight">
<?php for (\$i = 0; \$i <= 24; \$i++) : ?>
<option value="<?php echo \$i; ?>"><?php echo \$i; ?></option>
<?php endfor; ?>
</select>
`````` ## Getting Order Cost from Order Line in MDX

By : user3380959
Date : March 29 2020, 07:55 AM
it should still fix some issue Does the below work? I have got rid of unnecessary crossjoin, and put the distinct function on the [Order Line Details].[Order Number].Children and used the SUM function to add up the Order Line Order Cost against the order numbers.
code :
``````SUM(
DISTINCT([Order Line Details].[Order Number].Children)
, [Measures].[Order Line Order Cost]
)
``````
``````WITH
SET DistinctOrderNumbers AS
DISTINCT(EXISTING [Order Line Details].[Order Number].Children)

MEMBER [Measures].[Order Cost] AS
SUM(DistinctOrderNumbers, [Measures].[Order Line Order Cost])

SELECT NON EMPTY { [Measures].[Order Cost] } ON COLUMNS,
NON EMPTY { ([Reseller].[Reseller].[Reseller].ALLMEMBERS ) } ON ROWS
FROM [BI Cube]
``````
``````WITH
SET DistinctOrderNumbers AS
DISTINCT(EXISTING [Order Line Details].[Order Number].Children)

MEMBER [Measures].[Order Cost] AS
AVG(DistinctOrderNumbers, [Measures].[Order Line Order Cost])

SELECT NON EMPTY { [Measures].[Order Cost] } ON COLUMNS,
NON EMPTY { ([Reseller].[Reseller].[Reseller].ALLMEMBERS ) } ON ROWS
FROM [BI Cube]
`````` ## Difference among amortized cost, average cost, and expected cost

By : AXMT
Date : March 29 2020, 07:55 AM
hope this fix your issue Average cost of an algorithm is literally based on taking the average cost for each possible case the algorithm may work on, and dividing it by the number of said cases. If algorithm may work on 4 different inputs A,B,C,D in x, 2x, 3x, and 4x time, then it's average cost would be;
code :
``````(x + 2x + 3x + 4x) / 4 = 2.5 * x.
``````
``````(0.5 * x + 0.3 * 2x + 0.1 * 3x + 0.1 * 4x) = 1.8 * x.
`````` ## How do I match up what cost center an employee was in given the date of a work order when the employee changes cost cent

By : user2280159
Date : March 29 2020, 07:55 AM
this will help You can use the LEAD operator to get data from the 'next row'. In your case, you want to find the date that an employee stopped working for a given cost center, in addition to the date they started. In other words, for each cost center, the 'stop' date is the date they started working at the next center, or the 'start' date from the next record, if sorted by date.
code :
``````SELECT
W.WORKORDER_NAME,
TO_DATE(W.ASSIGNMENT_START) ASSIGNMENT_START,
E.COST_CENTER_ID

FROM
RPT.T_WORKORDER W
LEFT JOIN (
SELECT e1.EMPLOYEE_ID,
e1.COST_CENTER_ID,
e1.COST_CENTER_CHANGE_EFFECTIVE,
OVER (PARTITION BY e1.EMPLOYEE_ID
ORDER BY e1.COST_CENTER_CHANGE_EFFECTIVE
) AS COST_CENTER_CHANGE_END
FROM HR.T_EMPLOYEE_ALL e1
) E ON W.TECHNICIAN_BADGE_ID = E.EMPLOYEE_ID
AND  W.ASSIGNMENT_START >= E.COST_CENTER_CHANGE_EFFECTIVE
AND (W.ASSIGNMENT_START <  E.COST_CENTER_CHANGE_END OR E.COST_CENTER_CHANGE_END IS NULL)
WHERE
ASSIGNMENT_START >= '2018-12-01'
AND ASSIGNMENT_START <= '2018-12-31' 