BR
asked on
selecting both the price and sum(price ) with mysql statement
Dear Experts,
I have a very long sql statement. Below you may see the sort version of the sql. However I need more information like both the price and the SUM of the prices. How can I do that together? Can I use it like this?
I have a table that shows orders, I fetch the data and info from two tables, I show the prices but I want to show at the bottom of the table the total price too
is it possible to select data like below code? if I select the same column with SUM ( price ), and only price itself, how can I fetch the price and SUM (price) data?
how about SUM of the prices?
I need to both select the order.price and SUM(order.price)
I have a very long sql statement. Below you may see the sort version of the sql. However I need more information like both the price and the SUM of the prices. How can I do that together? Can I use it like this?
I have a table that shows orders, I fetch the data and info from two tables, I show the prices but I want to show at the bottom of the table the total price too
is it possible to select data like below code? if I select the same column with SUM ( price ), and only price itself, how can I fetch the price and SUM (price) data?
$sql = "SELECT order._key, SUM (order.price), order.price, products.id, products.nkolayalis FROM order, products WHERE order.urunid = products.id";
$result = $conn->query($sql);
// output data of each row
while($row = $result->fetch_assoc()) {
$_key= $row["_key"];
$price= $row["price"];
how about SUM of the prices?
I need to both select the order.price and SUM(order.price)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So you suggest, I should use two Select sql sentence right?Exactly that.
ASKER
thank you
ASKER
Thank you Vitor Montalvao
ASKER
So you suggest, I should use two Select sql sentence right?
That makes sense. Thank you