1

I have a script that sums everything in te field "total" and its ok.

$cleaner = $connection->query("SELECT *,SUM(total) as total FROM ventas where fecha='$datenow'");

but I want to create more filters, when the caja is nails

$cleanerx = $connection->query("SELECT *,SUM(total) as total FROM ventas where fecha='$datenow' and caja='NAILS'");

why is not working, I read the tutorials at php but I don't understand why is not working.

1 Answer 1

1

you can do it like this:

$cleaner = $connection->query("SELECT *,SUM(total) as total,(SELECT SUM(total) as total FROM ventas where fecha='$datenow' and caja='NAILS') as totalnails FROM ventas where fecha='$datenow'");
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much for your help!
your welcome please accept the answer if its help full to you :)
Hi, sorry for the inconvenience, we have a problems but i have a caja named "NAILS/SALON" only filtered with the date and the caja ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.