帮助使用 Access 创建交叉表查询
我正在尝试进行交叉表查询(使用访问表),但我在编写内部联接语句时迷失了。 我的最终结果应该是“QueryResult”。
表1保存基金信息, 表2是基金拥有的数据类型 Table3是将数据的代码转换为table2中的类型数据,Table4保存数据。
Table1
FundID FundName
1 Fund1
2 Fund2
3 Fund3
4 Fund4
5 Fund5
6 Fund6
7 Fund7
Table2
TypeID TypeName
1 Balance
2 Yield
3 Fees
4 Deposits
5 Withdraws
Table3
CodeID TypeID
KT111 1
KT112 2
KT113 3
KT115 3
KT116 4
KT117 4
KT118 5
KT119 5
Table 4
CodeID FundID DataVal
KT111 1 1000
KT116 2 40
KT118 3 30
KT119 3 30
KT118 2 10
KT119 2 50
KT111 2 3000
KT111 3 2000
KT112 1 1.5
KT112 2 1.0
KT112 3 0.5
PS:Table4 包含很多行,然后在此处显示我不需要的代码。
QueryResult
FundID Balance Yield Fees Deposits Withdraws
1 1,000 1.5 555 40 60
2 3,000 1.0 155 20 60
3 2,000 0.5 255 70 60
获取查询结果的正确语句是什么? (我迷失了内部连接......) 还有一种方法可以对某些数据求和,并显示 table4 中其他数据的值(不求和)吗?
谢谢!
I'm trying to make a crosstab query (with access tables), But I got lost writing the inner joins statements.
My end result suppose to be the "QueryResult".
Table1 holds the fund information,
Table2 are the type of data the funds have
Table3 is a conversion from the codes of the data to the type data in table2, and Table4 holds the data.
Table1
FundID FundName
1 Fund1
2 Fund2
3 Fund3
4 Fund4
5 Fund5
6 Fund6
7 Fund7
Table2
TypeID TypeName
1 Balance
2 Yield
3 Fees
4 Deposits
5 Withdraws
Table3
CodeID TypeID
KT111 1
KT112 2
KT113 3
KT115 3
KT116 4
KT117 4
KT118 5
KT119 5
Table 4
CodeID FundID DataVal
KT111 1 1000
KT116 2 40
KT118 3 30
KT119 3 30
KT118 2 10
KT119 2 50
KT111 2 3000
KT111 3 2000
KT112 1 1.5
KT112 2 1.0
KT112 3 0.5
P.S: Table4 holds much rows then shown here with codes which I do not need.
QueryResult
FundID Balance Yield Fees Deposits Withdraws
1 1,000 1.5 555 40 60
2 3,000 1.0 155 20 60
3 2,000 0.5 255 70 60
What is the right statement to get the query result? (I got lost on the inner joins...)
Is there also a way to sum some of the data, and show the value (without summing) of other data from table4?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我不太确定您的所有要求,但这可能会帮助您开始:
结果:
while I am not exactly sure of all of the requirements you have, this might get you started:
Results: