Answer the question
In order to leave comments, you need to log in
How to calculate the correct statistics from the database?
Hello!
Essence such, there is a table finance
In it records of a type
id | dates | manager | office | finance
1 | Date | Vasya | Gagarin | 15000
2 | Date | Petya | Gorky | 14000
3 | Date | Vanya | Gagarin | 9000
how to formulate a query so that the records are summarized and displayed like this:
Gorky 14000
Gagarin 24000
I do this, but finances are not displayed:
$result = mysql_query("SELECT DISTINCT office
FROM finance where dates
BETWEEN '".$_GET['dateo']."' AND '".$_GET['datep']."' group by office");
Answer the question
In order to leave comments, you need to log in
Hello.
Here is a query like this
SELECT office, SUM(finance)
FROM finance
WHERE dates BETWEEN '".$_GET['dateo']."' AND '".$_GET['datep']."'
GROUP BY office
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question