I want to get the sum per day by its specified date, show the sum and the tenant name on it. It should be like this. Does it have any possible way to construct it right??
tenant_id tenant_name Total Amount
-----------------------------------
123 SAMPLE 37100
use both column in group by like below
group by tenant_id ,tenant_name
so your query will be
select s.tenant_id ,i.tenant_name,
sum(s.amount) as total
from sales_data s left join
Tenant_info i
on s.tenant_id=i.tenant_id
group by s.tenant_id ,i.tenant_name
Note: maximum db throwns error if you have not put the selection column in group by in times of using aggregate function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.