I have 160 products in a table (one columns for each product).
Tables structure is like:
RM
Customer
Prd1Rev
Prd2Rev
Prd3Rev
Prd4Rev
.....
Prd160Rev
What will be the query to find top 50 product's revenue?
And what will be the query to find top 50 product's revenue and the RM?
something like this
Regards
Ria
Tables structure is like:
RM
Customer
Prd1Rev
Prd2Rev
Prd3Rev
Prd4Rev
.....
Prd160Rev
What will be the query to find top 50 product's revenue?
And what will be the query to find top 50 product's revenue and the RM?
something like this
Code:
SELECT TOP 50 SUM(RD.REVENUE1 + RD.REVENUE2) AS REVENUE, ADV.RM, ADV.RMNAME, ADV.CODE, RD.[RM Code], RD.RM
FROM tbl_ADV AS ADV INNER JOIN tbl_Revenue AS RD ON ADV.RM = RD.RM
GROUP BY ADV.RM, ADV.RMNAME, ADV.CODE, RD.[RM Code], RD.RM
ORDER BY SUM(RD.REVENUE1 + RD.REVENUE2) DESC
Regards
Ria