开发者

using distinct keyword in SQl query

开发者 https://www.devze.com 2023-02-17 20:08 出处:网络
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?

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

精彩评论

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

关注公众号