使用主表订购所有报告. [英] Using a Master table for ordering all the reports.

查看:97
本文介绍了使用主表订购所有报告.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我们有许多报告,其中包含始终以特定顺序显示的两个三个字段.

为了方便起见,DB架构师设计了一个主排序表,该表保存了分配有数值的2-3个字段的排序.即
Ordering_Master

Hi All,

We have a number of reports having two-three fields that are always displayed in a particular order.

For convenience, the DB architect has designed a master ordering table that saves the ordering of the 2-3 fields with numerical values assigned to them. i.e.
Ordering_Master

Group1 	Order1	        Group2		Order2
PAM	1	 	HNWI		1
PAM	1	 	Hedge Funds	2
PAM	1	 	PFs		3
PAM	1	 	ETFs		4
PIM	1	 	Pvt Insts	1
PIM	1	 	Banks		2
PIM	1	 	Trusts		3


现在,我们还有另一个表可用于生成几乎所有报告,即
Transaction_Master


Now, we have another table that is used for driving almost all of our reports i.e. the
Transaction_Master

Id	      Name	   Record_Type	Close_Date	Status	Role__c	Group1 Group2       
a0L7000000Cyk0fEAB	84001166 	Open Opportunities	00:00.0	 Forecast	Sales - Gov - West & MidWest	PAM	ETFs
a0L7000000Cyk0gEAB	84001167	 Open Opportunities	00:00.0	 Forecast	Sales - Gov - West & MidWest	PAM	 PFs
a0L7000000Cyk0hEAB	84001168	 Open Opportunities	00:00.0	 Forecast	Sales - Gov - West & MidWest	PAM	 HNWI
a0L7000000A1kEeEAJ	82949995	 Open Opportunities	00:00.0	 Forecast	Business - Index and Analytics	PIM	Banks
a0L7000000AusDkEAJ	83431781	 Open Opportunities	00:00.0	 Forecast	Sales - Gov - Boston	PAM	HNWI


现在,我试图将上述2个表(即Transaction_Master& Group1&上的Ordering_Master表Group2字段,但是我正在重复行.

我的目标是将这两个表和获得Order1& Ordering_Master表中的Order2列,然后按Order1和Order2列对结果集进行排序,即
按订单1排序,订单2

任何帮助将不胜感激.

谢谢,
Aryan.


Now, I am trying to make a join of the above 2 tables i.e. of the Transaction_Master & Ordering_Master tables on the Group1 & Group2 fields, however I am getting repeating rows.

My aim to join these two tables & get the Order1 & Order2 columns from the Ordering_Master table and then sort the resultset by the Order1 and then the Order2 column i.e.
Order By Order1 , Order2

Any help would be much appreciated.

Thanks,
Aryan.

推荐答案

select order1, order2
from transaction_Master tm
    Join ordering_master om ON tm.group_1= om.group1 and tm.group_2=om.group2
order by order1, order2


越来越重复行,只需在其中添加DISTINCT子句.还是我在您的问题中遗漏了某些东西?
If you are getting repeating rows, just add a DISTINCT clause in. Or am I missing something in your question?


不建议总是使用不同的内容.

只需使用此查询

Distinct is not recommend always.

Just use this query

select order1, order2
from transaction_Master tm
    Join ordering_master om ON tm.group_1= om.group1 and tm.group_2=om.group2
order by order1, order2


这篇关于使用主表订购所有报告.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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