输出与ms访问中的数据库不匹配 [英] The output is not matching with database in ms access

查看:56
本文介绍了输出与ms访问中的数据库不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ms访问数据库中的Tb_Sch_Time_Table记录如下:


 Sch_Date Session Faculty_Code课程
4/15/2013 1 DM CL2
4/15/2013 2 VRV CL2
4/16/2013 1 VRV CL2
4/16/2013 2 AKR CL2
4/17/2013 1 GS CL2
4/17/2013 2 VRV CL2
4/18/2013 1 GS CL2
4/18/2013 2 DS CL2




来自上述记录的
我希望输出如下



 Sch_Date Session 1 Session 2 
4/15/2013 DM VRV
4/16/2013 VRV AKR
4/17/2013 GS VRV
4/18/2013 GS DS



获取以上输出我在ms访问数据库中写入查询如下



 TRANSFORM MAX(Faculty_Code)
SELECT 课程
FROM Tb_SCh_TI me_Table 其中 Course = ' CL2'
GROUP BY 课程
PIVOT [会话]





i在msaccess数据库中写入以上查询,当我按如下方式执行输出时



课程1 2 3 
CL2 VRV VRV RAM





输出与Tb_Sch_Time_Table不匹配。



我的查询中有什么问题。



请帮帮我。



问候,

Narasiman P.

解决方案

看看这里:传输语句(访问) [ ^ ]



试试这个:

 TRANSFORM MAX( Faculty_Code)
SELECT Sch_date
FROM Tb_SCh_TIme_Table where Course = ' CL2'
GROUP BY 课程
PIVOT [会话]


试试这个

 选择 Sch_Date,[Session1],[Session2] 来自选择 Sch_Date,会话,Faculty_Code,课程
来自 Tb_Sch_Time_Table 其中 Course = ' CL2') s
pivot(max(Faculty_Code) for (Session)中的code-keyword>([ 1 ] [Session1],[< span class =code-digit> 2 ] as [Session2]))pvt



这样可行,但是如果不能正常工作,请更改枢轴中的聚合函数并尝试...


In Tb_Sch_Time_Table records as follows in ms access database

Sch_Date     Session Faculty_Code  Course
4/15/2013	1	DM           CL2
4/15/2013	2	VRV          CL2
4/16/2013	1	VRV          CL2
4/16/2013	2	AKR          CL2
4/17/2013	1	GS           CL2
4/17/2013	2	VRV          CL2
4/18/2013	1	GS           CL2
4/18/2013	2	DS           CL2



from the above records i want the output as follows

Sch_Date    Session 1  Session 2
4/15/2013    DM          VRV
4/16/2013    VRV         AKR
4/17/2013    GS          VRV
4/18/2013    GS          DS



for getting a above output i written the query in ms access database as follows

TRANSFORM MAX(Faculty_Code)
SELECT Course
FROM Tb_SCh_TIme_Table where Course = 'CL2'
GROUP BY  Course 
PIVOT [Session]



i written the above query in msaccess database when i execute output as follows

Course    1     2     3
CL2      VRV    VRV   RAM



the output is not matching with the Tb_Sch_Time_Table.

what is the problem in my query.

please help me.

Regards,
Narasiman P.

解决方案

Have a look here: TRANSFORM Statement (Access)[^]

Try this:

TRANSFORM MAX(Faculty_Code)
SELECT Sch_date
FROM Tb_SCh_TIme_Table where Course = 'CL2'
GROUP BY  Course 
PIVOT [Session]


try this

select  Sch_Date,[Session1],[Session2] from (select Sch_Date,Session,Faculty_Code,Course
from  Tb_Sch_Time_Table where Course = 'CL2') s 
pivot (max(Faculty_Code) for (Session) in ([1] as [Session1],[2] as [Session2]) ) pvt


this will work but if dosen''t work change the aggregate function in pivot and try...


这篇关于输出与ms访问中的数据库不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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