Code:
SELECT sales.RSMID, rsm.FName, rsm.LName, sales.ID AS SalesID, sales.DateSold, sales.CustName, sales.SysConfig, host.HostName, salestype.SaleType, sales.Amount, [b](Select Sum(B.Amount) From Sales B Where B.RSMID=Sales.RSMID AND Month(B.DateSold)=1) AS MTD[/b], sales.Margin, rsm.Goal
FROM ((rsm INNER JOIN sales ON rsm.ID = sales.RSMID) INNER JOIN host ON sales.HostVend = host.ID) INNER JOIN salestype ON sales.Type = salestype.ID
GROUP BY sales.RSMID, rsm.FName, rsm.LName, sales.ID, sales.DateSold, sales.CustName, sales.SysConfig, host.HostName, salestype.SaleType, sales.Amount, sales.Margin, rsm.Goal
HAVING Month(DateSold)=1
I need to Order by MTD.
When ever I try I get a syntax error. I've tried ORder By after the Having and I've tried inside the sub query - no luck.
Thanks