у меня есть 2 таблицы
InvoiceDetail as
--------------------------------------------
| Id | Invoicesubdt | Amount | Orgid |
| 1 | 02-05-2017 | 100 | 29 |
| 2 | 08-06-2019 | 1200 | 30 |
--------------------------------------------
Orgdetial
-----------------------------
| Id | company_name |
| 29 | company.. |
| 30 | Company1 |
-----------------------------
Для регистрации
Orgdetial.Id=InvoiceDetail.Orgid
Мне нужен результат как
-------------------------------------------------
| Company_name | Total_Amount | Month | Year |
| Company1 | 100000 | 10 | 2018 |
SELECT YEAR(InvoiceSubDt)as Years, MONTH(InvoiceSubDt) as Months , sum (Amount) AS TOTALCOUNT
FROM InvoiceDetail
GROUP BY YEAR(InvoiceSubDt), MONTH(InvoiceSubDt)