我想要一个这个表的Sql查询 [英] I want a Sql Query for this table

查看:55
本文介绍了我想要一个这个表的Sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用的是表 tblSurvey_quastions ..

表结构是这样的。

客户Quastion 
sudeer Q1
sudeer Q2
sudeer Q3







我需要这样的值



客户Quastion Quastion1 Quastion2 
sudeer Q1 Q2 Q3





我怎样才能得到这个?



请帮帮我....

解决方案

  SELECT   TOP  1 )ID,Client,STUFF(( SELECT   DISTINCT  ' ,' +问题 FROM  dbo.T emporary 
FOR XML PATH(' ')), 1 1 ' '来自临时其中 Client = ' Sudeer'

Temporary是表的名称


In my project I am using a table tblSurvey_quastions..
The table structure is like this.

client         Quastion
sudeer           Q1
sudeer           Q2
sudeer           Q3




I need the values like this

client            Quastion     Quastion1       Quastion2
sudeer              Q1           Q2             Q3



How can I get this?

Please help me....

解决方案

SELECT TOP(1) ID,Client,STUFF((SELECT DISTINCT ',' + Question FROM dbo.Temporary  
FOR XML PATH ('')), 1, 1, '') from Temporary where Client='Sudeer'

Temporary is the name of the Table.


这篇关于我想要一个这个表的Sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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