我写的代码如下; [英] i written my code as follows;

查看:71
本文介绍了我写的代码如下;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询如下;

 选择 *  FROM  Tb_SCh_TIme_Table P PIVOT(MAX(Faculty_Code) FOR 会话 IN ([ 1 ],[ 2 ],[ 3 ],[  4 ])) AS  PVT 其中课程= '  PH2' 订单  日期; 



当我运行上面的查询时输出如下;

日期课程1 2 3 4 

16/1/2013 PH2 GS
16/1/2013 PH2 NR
16/1/2013 PH2 CM



形成我的输出我希望改变如下;

日期课程1 2 3 4 

16 / 1/2013 PH2 GS
16/1/2013 PH2 NR,CM



i希望教师CM在同一行16/1/2013日期.dont想要下一行的教师代码CM ..



我的查询怎么办?我的输出正确。我的上述查询需要进行哪些更改。



请帮助我。

解决方案

< blockquote>您好会员8054539,



看起来您想要分组行,您可以使用 GROUPBY SQL关键字

*请参阅更多帮助



并在SELECT字段中创建一个 CONCAT 来创建NR,CM列

*参见更多帮助 [ ^ ]。



干杯,

Edo


my query as follows;

select * FROM Tb_SCh_TIme_Table P PIVOT (MAX(Faculty_Code) FOR Session IN ([1],[2],[3] ,[4])) AS PVT  where course = 'PH2' order by date;


when i run my above query the output as follows;

 Date       Course      1      2      3     4

16/1/2013   PH2         GS
16/1/2013   PH2                             NR
16/1/2013   PH2                             CM


form my output i want the change as follows;

 Date       Course      1      2      3     4

16/1/2013   PH2         GS
16/1/2013   PH2                            NR,CM


i want the faculty CM in same line 16/1/2013 date.dont want to faculty code CM in Next Line..

from my query how can i do. to Get my output correct.what changes is needed from my above query.

help me please.

解决方案

Hi Member8054539,

Looks like you want to group rows, you can use the GROUPBY SQL keyword
* see more help on that.

And in the SELECT fields make a CONCAT to create the NR,CM column
* see more help[^] on that.

Cheers,
Edo


这篇关于我写的代码如下;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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