logo
down
shadow

How to sum order cost


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;


Share : facebook icon twitter icon
minimum cost path through a cost matrix with positive and negative cost

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

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>
<head>
<title>Lightbulb sales</title>
</head>
<body>

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

$name = $_POST['name'];
$address = $_POST['address'];
$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 "Address: " . $address . "<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>
<head>
<title>Light bulb Sales</title>
</head>
<body>
<form action="light.php" method="post">
<h2>Welcome to Light of your Life Light bulb Sales</h2>
<table>
<tr>
    <td>Buyer's Name:</td>
    <td><input type="text" name="name" size="30" /></td>
</tr>
<tr>
    <td>Street Address:</td>
    <td><input type="text" name="address" size="30" /></td>
</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

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

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

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,
    W.TECHNICIAN_BADGE_ID,
    E.COST_CENTER_ID

FROM
    RPT.T_WORKORDER W
LEFT JOIN (
       SELECT e1.EMPLOYEE_ID,
              e1.COST_CENTER_ID,
              e1.COST_CENTER_CHANGE_EFFECTIVE,
              LEAD(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'
AND W.TECHNICIAN_BADGE_ID = '207361'

ORDER BY 2
Related Posts Related Posts :
  • How to create a database snapshot in SQL Server 2008 R2
  • Query speed and expressions with constant value
  • How to do a complex calculation as this sample
  • Passing a ResultSet into a Postgresql Function
  • Netsuite custom formula field using a CASE statement with multiple WHEN conditions returning "invalid expression&qu
  • Execute query command (dynamic sql) runs faster than ordinary query
  • How to extract only numbered rows from a column
  • INSTEAD OF DELETE trigger (Postgresql)
  • Oracle Apex, when a report with sql is created, how do i get it return after entering in to a text box?
  • Select records based on two tables where one column in one table starts with the records from another tables column usin
  • How to write select using two ids combination in Oracle 11g
  • Frequently use of 'UPDATE STATISTICS WITH FULLSCAN' is normal?
  • need query for this simple pulling data sql server
  • Sql query by using decode to show grades of employee
  • Not a single function error in Oracle
  • Oracle SQL optimizer's behavior when dealing with ORs and row-independent predicates (such as functions returning same v
  • Combining output of two or more select statement
  • Must Declare Scalar Variable Exception
  • Postgres Calculate Difference Using Window Functions
  • SQL Server : unsure how to retrieve selected records
  • SQL unique field: concurrency bugs?
  • Query to get the next identity?
  • SQL Server Adding summing values based on the month
  • Join on month if available else join on latest month
  • How to solve error: ORA-01406 fetched column value was truncated?
  • Selecting Field Multiple Times using OR
  • Which SQL datatype can be used to store mobile numbers in numeric forms, without including characters like brackets and
  • Oracle SQL - "Not a group by expression" after adding CASE statements
  • Runnning total of unique string values in column over days
  • VB.Net to AccessDB by SQL - INSERT INTO with parameters error
  • SQL/Excel/VBA - UPDATE query: 'Syntax Error (missing operator) in query expression'
  • Code to combine two sql queries
  • Setting SQL Date field value based off Week Number and Day Number Field
  • SQL query to find matching records but with differences in case sensitivity?
  • How to sort record inside views in SQL Server 2008
  • How to link the output of teradata sql query to an excel sheet?
  • Matching sets in SQL when cross-referencing
  • error even after following Microsoft format in SQL
  • Increase price by percentage, results rounded
  • Can we Use "Case" in a ColdFusion Query-of-Query
  • displaying 'Active' for a row which has 'A' as value
  • Using pattern search in SQL Server Query
  • SQL - how to group transactions for a certain date pattern?
  • How to Index SQL with multiple AND conditions nested inside OR
  • SQL rank with priority
  • Does BigQuery support SubQueries?
  • Any ideas for persisting H2 Database In-Memory mode transaction?
  • How to improve SQL query performance (correlated subqueries)?
  • Filter repeated columns in Oracle
  • SQL Server join on whichever column has value populated
  • use sql stored procedure to insert data which is returned from a query stored in a table
  • Query not working1
  • SQL - using an alias in a where clause in a subquery
  • How to search for a whole word with special char using oracle contains?
  • Production Perfomance of using SELECT * statements?
  • String concatenation not working as expected in SELECT statement
  • How to detect which stored procedures UPDATE or INSERT into a certain TABLE?
  • Select statement inside CASE - SQL
  • .Net Float error 4 - float(4) = 4.44089209850063E-16
  • How to show as column to recursive rows in a table With SQL Server
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org