using distinct keyword in SQl query
I want to retrieve a table which has repeated values in column1, column2 and column3. column 4 has different sets of data corresponding to value in column3. How should I query such a table?
Ex:
District | City 开发者_JAVA技巧 | Place
----------|----------------|-------------
bangalore | bangalorerural | indiranagar
bangalore | bangalorerural | jayanagar
I want to display bangalore, bangalorerural once with indiranagar and jayanagar in other rows.
UNPIVOT is what you're after
http://archive.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=UNPIVOTData
精彩评论