你的查询工作。但我想要最后的ouptut.for如何查询查询。请帮助我 [英] your query working., but i want the final ouptut.for that how to wirte the query.help me please
问题描述
在MS Access数据库中,如下所示:
In MS Access database as follows:
Date Session Course Faculty_Code
25/01/2013 1 AFF GS
25/01/2013 1 AFF VB
我希望输出如下:
I would like the output as follows:
Date Session Course Faculty_Code
25/01/2013 1 AFF GS,VB
当我尝试你的查询输出显示为如下:
我试过这个查询:
When I tried your query output shows as follows:
I tried with this query:
TRANSFORM First(Tb_SCh_TIme_Table.Faculty_Code) AS a
SELECT Tb_SCh_TIme_Table.Sch_Date, Tb_SCh_TIme_Table.Course
FROM Tb_SCh_TIme_Table
GROUP BY Tb_SCh_TIme_Table.Sch_Date, Tb_SCh_TIme_Table.Course
PIVOT Tb_SCh_TIme_Table.Session;
我尝试过您的查询输出显示如下;
When I tried your query output shows as follows;
Date Session Course Faculty_Code
25/01/2013 1 AFF GS
在上面的输出中没有显示两个教员名称只显示GS Faculty_Code
。我想要VB Faculty_Code
。
我需要最终输出如下:
In the above output not showing the Two faculty name only shows the GS Faculty_Code
. I would like the VB Faculty_Code
also.
I need the final output as follows:
Date Session Course Faculty_Code
25/01/2013 1 AFF GS,VB.
对于同一日期,课程和课程,不同的教师需要上课,我也需要提及两个Faculty_Code。 />
我如何编写查询以获得上面提到的最终输出。
请帮助我。我怎么能这样做?
谢谢。
For the same date, session and course, different faculty takes class I need to mention both Faculty_Code also.
How can I write the query to get the final output as I mentioned above.
Please help me. How can I do it?
Thanks.
推荐答案
你好,
你可以尝试以下SQL
Hi,
Can you try the below SQL
SELECT t1.Sch_Date,t1.Session,t1.Course,
Faculty_Code =REPLACE( (SELECT Faculty_Code AS [data()]
FROM [tb_SchTime_Table] t2
WHERE t2.Sch_Date = t1.Sch_Date and t2.Course=t1.Course
FOR XML PATH('')
), ' ', ',')
FROM [tb_SchTime_Table] t1
GROUP BY Sch_Date,Course,Session ;
最好的问候
Muthuraja
Best Regards
Muthuraja
这篇关于你的查询工作。但我想要最后的ouptut.for如何查询查询。请帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!