How to select one field from view in MySQL?
How can do the following query in MySQL?
Select SUM(T1.Amount) From ( Select Distinct PersonName,Amount From tblusers as T1 where city ="xxx" )
MySQL requires an alias on a derived table or subquery. So you will want to use the following:
Select SUM(t1.Amount) From ( Select Distinct PersonName, Amount From tblusers where city ="xxx" ) t1
You should be able to use the following though depending on your needs:
select personName, sum(Amount) from tblusers where city = "xxx" group by personName
Or if you just want to return the sum, you can use:
select sum(Amount) from tblusers where city = "xxx" group by personName
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]