loveindia Posted June 20, 2016 Report Posted June 20, 2016 this is what you should do to get your desired result set man.... SELECT a.BusinessEntityID, SUM(b.SalesLastYear) AS prevYear, SUM(b.SalesYTD) AS YTD , SUM(b.SalesLastYear) + SUM(b.SalesYTD) AS sales FROM Sales.SalesPerson a INNER JOIN Sales.SalesTerritory b ON a.TerritoryID = b.TerritoryID GROUP BY a.BusinessEntityID Quote
loveindia Posted June 20, 2016 Report Posted June 20, 2016 premathoo mee loveindia signing off man... Quote
vikuba Posted June 20, 2016 Report Posted June 20, 2016 group by tharavatha chudhaam.. for group by theeseyi...and add the two variables. aa summation work aitey...then groupby ni CTE lo cheyochu or direct ga cheyochu chk the summation. I am hoping both sums are INTs and amounts Quote
loveindia Posted June 20, 2016 Report Posted June 20, 2016 2 hours ago, vikuba said: group by tharavatha chudhaam.. for group by theeseyi...and add the two variables. aa summation work aitey...then groupby ni CTE lo cheyochu or direct ga cheyochu chk the summation. I am hoping both sums are INTs and amounts Variables ki enni values pass chesina it will take first value only man. For ts, put all d data into a CTE andjoin that to the result set you have currently and get what you want man.. simple and straight forward... good luck. Quote
vikuba Posted June 20, 2016 Report Posted June 20, 2016 4 minutes ago, loveindia said: Variables ki enni values pass chesina it will take first value only man. For ts, put all d data into a CTE andjoin that to the result set you have currently and get what you want man.. simple and straight forward... good luck. CTE gives clarity - the best. but to do this one should have clarity on what he is doing also Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.