开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜