Please consider below sql query by which i want to get data of last month.
SELECT opp.opp_partner,
Sum(margin.clientquote) AS
ClientFeeLastMonth,
Sum(margin.grossmargin) / Count(grossmargin) AS
AvgMarginLastMonth,
0 AS ClientFeeLastYear
,
0 AS
AvgMarginLastYear
FROM [dbo].[tbproject_margindetails] margin
INNER JOIN tbopportunitydetails opp
ON margin.opportunity_id = opp.opportunityid
WHERE opp.servicearea = 'Technology'
AND opp.status <> ''
AND Month(opp.updatedon) = Month(Getdate()) - 1
AND Year(opp.updatedon) = Year(opp.updatedon)
How to get data of previous month