There are only two ways to do it - either a static pivot, or a dynamic pivot. (There is a third way, but that is even more code).If you have only 30 cities, and if the cities are known in advance, I would recommend using static pivot. It is not that much code to write, and it is as simple as this:SELECT *FROM YourTablePIVOT( MAX(salary) FOR City IN ([1],[2],[3],[4],[5],[6],[7],[8 ],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23],[24],[25],[26],[27],[28],[29],[30]))P;
If you don't know the cities in advance, then you will need dynamic pivoting. See Madhivanan's page here for code and examples: http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx