crEA-tEch
02-17-2007, 06:17 AM
Hi there...
I think this is a simple question, am not sure!
I've got to order a database query going by what a value totals in another table.
I'm querying the staff table to get a list of staff - Then with their staff id's, I'm querying another table to get their total sales, and total sales units.
Everything is fine but I need to order the table by the highest sales to the lowest sales... Here's my initial query...
$query_o = "SELECT * FROM staff ORDER BY figures.sum(service_price)";
(The syntax is wrong... but is it something like that?)
This is the next query...
$sql = "SELECT SUM(service_price) AS total FROM figures WHERE staff_id='$staff_id_queried' AND " . join (" AND " , $cond ) ." ";
(This syntax i know is correct)
Anybody know what I'm missing??
Thanks in advance,
Nick
I think this is a simple question, am not sure!
I've got to order a database query going by what a value totals in another table.
I'm querying the staff table to get a list of staff - Then with their staff id's, I'm querying another table to get their total sales, and total sales units.
Everything is fine but I need to order the table by the highest sales to the lowest sales... Here's my initial query...
$query_o = "SELECT * FROM staff ORDER BY figures.sum(service_price)";
(The syntax is wrong... but is it something like that?)
This is the next query...
$sql = "SELECT SUM(service_price) AS total FROM figures WHERE staff_id='$staff_id_queried' AND " . join (" AND " , $cond ) ." ";
(This syntax i know is correct)
Anybody know what I'm missing??
Thanks in advance,
Nick
