I have two tables
(1) MonthlyTarget {SalesManCode, TargetValue};
(2) MonthlySales {SalesManCode, SaleDate, AchievedValue};
I have to make a query that produces a result like the following table:
{SalesManCode, JanTar, JanAch, FebTar, FebAch,....., DecTar, DecAch}
What should be the query?
What database are you using? I have a stored procedure that simplifies doing that type of pivot for Microsoft SQL Server 2005 …
If you are using SQL Server 2005:
Run this to install the pivot_query procedure.
Here is an example like you described, the output looks like: