MS SQL查询将实际数据显示为列 [英] MS SQL Query to Display actual data as columns
问题描述
你好,
请帮助我解决这个问题。
我有一张桌子可以显示数据如下所示:
名称ID金额日期
Peter A $ 10 12/02/2013
Peter B $ 15 12/02/2013
Peter C $ 12 12/02/2013
Peter A $ 12 12/02/2013
Mary B $ 18 12/02/2013
Mary C $ 12 12/02/2013
James A $ 5 12/02/2013
我想从上面得到的内容如下所示。请帮我查询。
名称ABC
Peter $ 22 $ 15 $ 12
Mary $ 18 $ 12 < br $>
James $ 5
请协助我查询上述内容。
提前致谢。
Hello,
Please assist me with this issue.
I have a table that displays the data as is shown below:
Name ID Amount Date
Peter A $10 12/02/2013
Peter B $15 12/02/2013
Peter C $12 12/02/2013
Peter A $12 12/02/2013
Mary B $18 12/02/2013
Mary C $12 12/02/2013
James A $5 12/02/2013
What I want to get from the above is as shown below. So help me with the query please.
Name A B C
Peter $22 $15 $12
Mary $18 $12
James $5
Please assist me with the query for the above.
Thanks in advance.
推荐答案
10 12/02/2013
Peter B
10 12/02/2013
Peter B
15 12/02/2013
Peter C
15 12/02/2013
Peter C
12 12/02/2013
Peter A
12 12/02/2013
Peter A
这篇关于MS SQL查询将实际数据显示为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!