Always better to post your actual code - the code you have provided clearly won't work - there is no FROM clause
but in principle you might have something like
Code:
SELECT field1, field2, field3, iif(year=2017,year) as Yr, iif(month=September,month) as M1, SUM(iif month=September,Amount)) as M1Ttl, iif(month=July,month)) as M2, SUM(iif(month=July,Amount))as M2Ttl
FROM myTable
WHERE (field1 ="aa" And field2="bb" AND field3="cc")
AND ((Year = 2017) AND (Month =September) OR ((Year = 2018) AND mONTH = July))
GROUP BY field1, field2, field3,iif(year=2017,year), iif(month=September,month), iif(month=July,month)
Note Year and Month are reserved words and should not be used for field names tho I'm guess this is all pseudo code