将多个记录合并为一行 [英] Combine multiple records into single row

查看:76
本文介绍了将多个记录合并为一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是数据的组织方式:


vID答案


12满意

12营销

12是

15不满意

15技术

15否

32非常不满意

32营销

32是


我需要做的是拉一个记录集,每个vID是一行

并且每个答案都是行中的不同字段,所以它看起来好像这样的东西


vID答案1答案2答案3


12 Saitsfied Marketing Yes


等...

我不能完全理解这个一个。

This is how the data is organized:

vID Answer

12 Satisfied
12 Marketing
12 Yes
15 Dissatisfied
15 Technology
15 No
32 Strongly Dissatisfied
32 Marketing
32 Yes

What I need to do is pull a recordset which each vID is a single row
and each of the answers is a different field in the row so it looks
something like this

vID Answer1 Answer2 Answer3

12 Saitsfied Marketing Yes

etc...
I can''t quite get my mind wrapped around this one.

推荐答案

示例:
http://builder.com.com/5100-6388_14-6143761.html


只有你,PIVOT才有效有SQL SERVER 2005否则你将使用CASE方法



3月29日下午12:43,franzey < fran ... @ gmail.comwrote:
Examples:
http://builder.com.com/5100-6388_14-6143761.html

PIVOT will only work if you have SQL SERVER 2005 otherwise you will
use the CASE method.

On Mar 29, 12:43 pm, "franzey" <fran...@gmail.comwrote:

这是数据的组织方式:


vID答案


12满意

12营销

12是

15不满意

15技术

15否

32非常不满意

32营销

32是


我需要做的是拉一个记录集,每个vID是一行

,每个答案都是行中的不同字段,所以它看起来像

像这样的东西


vID答案1答案2答案3


12 Saitsfied Marketing Yes


等等...


我不能完全理解这一点。
This is how the data is organized:

vID Answer

12 Satisfied
12 Marketing
12 Yes
15 Dissatisfied
15 Technology
15 No
32 Strongly Dissatisfied
32 Marketing
32 Yes

What I need to do is pull a recordset which each vID is a single row
and each of the answers is a different field in the row so it looks
something like this

vID Answer1 Answer2 Answer3

12 Saitsfied Marketing Yes

etc...

I can''t quite get my mind wrapped around this one.



感谢您的链接。我只有SQL Server 2000所以PIVOT是

out。看起来我会做一些CASE语句。我是新手。

你知道我将使用上面例子的一般语法

得到这个滚动吗?



3月29日下午1:15,Jason Lepack < jlep ... @ gmail.comwrote:
Thanks for the link. I do only have SQL Server 2000 so the PIVOT is
out. Looks like I will be doing some CASE statements. I''m new at this.
Do you know the general syntax I would use using the above example to
get this rolling?


On Mar 29, 1:15 pm, "Jason Lepack" <jlep...@gmail.comwrote:

示例: http://builder.com.com/5100-6388_14-6143761.html


PIVOT只能工作如果您有SQL SERVER 2005,否则您将使用CASE方法




- 显示引用文本 -
Examples:http://builder.com.com/5100-6388_14-6143761.html

PIVOT will only work if you have SQL SERVER 2005 otherwise you will
use the CASE method.

- Show quoted text -



我自己从未做过。我刚刚找到了这些例子,并尝试了它们

并且他们工作了。如果你处理的数据集太大,那么它可能会很乏味。


我发现了一些更有活力的东西。这里是谷歌搜索
我使用的
字符串:


数据透视表sql server


干杯,<
Jason Lepack


3月29日下午2:07,franzey < fran ... @ gmail.comwrote:
I''ve never done it myself. I just found the examples and tried them
and they worked. If you''re dealing with too big of a dataset then it
may be tedious.

I''ve found some more that are more dynamic. Here''s the google search
string I used:

pivot table sql server

Cheers,
Jason Lepack

On Mar 29, 2:07 pm, "franzey" <fran...@gmail.comwrote:

感谢您的链接。我只有SQL Server 2000所以PIVOT是

out。看起来我会做一些CASE语句。我是新手。

你知道我将使用上面例子的一般语法

得到这个滚动吗?


3月29日下午1:15,Jason Lepack < jlep ... @ gmail.comwrote:
Thanks for the link. I do only have SQL Server 2000 so the PIVOT is
out. Looks like I will be doing some CASE statements. I''m new at this.
Do you know the general syntax I would use using the above example to
get this rolling?

On Mar 29, 1:15 pm, "Jason Lepack" <jlep...@gmail.comwrote:

示例: http://builder.com.com/5100-6388_14-6143761.html


只有拥有SQL SERVER 2005才能使用PIVOT,否则你将使用CASE方法获得

PIVOT will only work if you have SQL SERVER 2005 otherwise you will
use the CASE method.


- 显示引用的文字 - 隐藏引用的文字 -
- Show quoted text -- Hide quoted text -



- 显示引用的文字 -


- Show quoted text -



这篇关于将多个记录合并为一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆