基于一个字段的值构建查询但是将其分组为另一个字段? [英] Building a query based on one field?s value but grouping it by another?..

查看:75
本文介绍了基于一个字段的值构建查询但是将其分组为另一个字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好:


我刚刚学会了如何将交叉表查询放在一起,但是这个特别是添加了一个新的维度,我希望有人可以给我一些方向。我有以下表格


表格:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号

解决方案

嗨Keith


我对桌面有点惊愕,特别是在tblPrior和tblBudget中找到:

ProductName;文本;产品名称

它们应该在需要时从tblProduct派生出来......

我也想知道为什么有一个表tblPrior,它是否存储以前YearMonth''s?


好​​的,对于查询,我会将带有JOIN的tblProduct添加到master table中。 tblCreditRegion,当它始终保持整行的产品时。如果产品的查询表格与LEFT JOIN的不同,我想了解结构的原因和方式。

加入表后,将启用ProductType的添加。


Nic; o)



嗨Keith


我对桌面区域感到震惊,特别是在tblPrior和tblBudget中找到:

ProductName;文本;产品名称

它们应该在需要时从tblProduct派生出来......

我也想知道为什么有一个表tblPrior,它是否存储以前YearMonth''s?....


Nic; o)



Nico:

是的,它是存储前几个月的。事实上,Budget表和Prior表并没有直接绑定到我的DB,因为记录是通过我的DB写入它们的。相反,它们用于报告目的。这些实际上是在年初加载然后保持静态的表。我最初要求他们给我?产品ID?这样我就可以将它们绑定到动态的表中(每个记录代表[ProductID]的[GWP]值)。我导入了这些表,然后在ProductID上建立了一对多的关系,但我对如何将产品类型与我的查询联系起来(以非直接的方式),所以我包含了两个? ?产品名称? ?产品类别?对于预算和之前的表格,到目前为止,这是我知道怎么做的唯一方法?如果您有更好的参考产品类型的方式,将非常感激?我认为通过查询有一种方法,但我根本不知道如何


只需检查查询结果并检查或所有productID'(因此名称)是相同的在一排。如果他们是你可以像我建议的那样加入,否则你有问题,因为不同的产品可以有不同的类型和报告的一个......


Nic; o )

Hello:

I just learned how to put crosstabs queries together but this one in particular is adding a new dimension in which I was hoping someone could give me some direction. I have the following tables

The Tables:

Expand|Select|Wrap|Line Numbers

解决方案

Hi Keith

I''m a bit stunned about the tablefields, especially in tblPrior and tblBudget to find:
ProductName; Text; Product Name
They should be derived from the tblProduct when needed...

I also wonder why there''s a table tblPrior, is it to store previous YearMonth''s ?

OK, for the query I would add the tblProduct with a JOIN to the "master table" tblCreditRegion, when this always hold the product of the entire row. When the products differ in the queries the table is LEFT JOINing to, I would like to know why and how the structure should be.
Having JOINed the table will enable the addition of the ProductType.

Nic;o)


Hi Keith

I''m a bit stunned about the tablefields, especially in tblPrior and tblBudget to find:
ProductName; Text; Product Name
They should be derived from the tblProduct when needed...

I also wonder why there''s a table tblPrior, is it to store previous YearMonth''s ?....

Nic;o)


Nico:

Yes, it is to store previous years months. In fact, the Budget table and the Prior table are not directly tied to my DB in the sense that records are being written to them via my DB. Rather they are for reporting purposes. These are in fact tables that are loaded at the begin of the year and then left static. I originally requested that they give me ?Product ID? so that I could tie them to my tables that were dynamic (Each record represents a [GWP] value for each [ProductID]). I imported these tables and then did a one to many relationship on ProductID but I am lost on how to tie Product Type to my queries (In a non-direct way) so I included both the? ?Product Name? ?Product Type? to both the budget and prior tables, so far it was the only way I knew how to do it?. If you have a better way of referencing the Product Type that would be greatly appreciated?. I figure there is a way via queries but I simply don?t know how


Just check the result of the query and check or all productID''s (and thus the names) are identical on one row. When they are you can JOIN like I proposed, otherwise you have a problem, as different products can have different types and which one to take for reporting.....

Nic;o)


这篇关于基于一个字段的值构建查询但是将其分组为另一个字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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