我正在尝试解决以下问题:数据以表X的形式作为信息的外键组织在表中(它是ID,用于标识此表中的一组行归为一束,由特定的束缚实体在另一个表中)。因此,X的每个不同值在此都具有与其关联的多个行。我想过滤掉X的所有不同值,这些X的相关行包含Q列中的值“ ABC”。
即
数据如下所示:
Column X Column Q
-------- ---------
123 ABC
123 AAA
123 ANQ
456 ANQ
456 PKR
579 AAA
579 XYZ
886 ABC
Run Code Online (Sandbox Code Playgroud)
该查询应返回“ 456”和“ 579”,因为X的两个不同值在列Q中没有包含值“ ABC”的行。
我正在考虑使用减号函数(选择不同的X减号(选择不同的X,其中Q =“ ABC”))来完成此操作,因为我想要的只是X的不同值。但是我想知道是否有更有效的方法这样做可以避免子查询?例如,如果我可以在X上对表进行分区,并丢弃在Q中具有“ ABC”值行的每个分区?
我对Oracle优化器中的这种行为感到很困惑.这与联合CTE的所有操作有关.如果有人有任何想法我都是游戏.
--Relevant data structures:
--t_positionperf (index: POSITIONPERF_X1 (account_id, hist_date, security_id)
--t_positionhist (index: POSITIONHIST_X1 (position_id, hist_date, hist_type)
-- PK_T_POSITIONHIST (hist_date, position_id, hist_type)
--v_positiontype (very simple "case-when" translation of a tiny lookup table)
with q as (
select
pp.position_id, pp.hist_date, pp.account_id, pp.income, pp.expense,
ph.position_type_id, ph.price, ph.quantity, ph.factor, ph.daily_accrual,
n.daily_accrual as new_daily_accrual, nvl(n.is_loan, v.is_loan) as new_is_loan
from
t_positionperf pp
left outer join t_positionhist ph
on pp.position_id = ph.position_id
and pp.hist_date = ph.hist_date
and ph.hist_type = 'O' --the 'O' join set from t_positionhist
left …Run Code Online (Sandbox Code Playgroud) 我有以下问题.我想要一个名为MessageField的广泛抽象类型.MessageField的运行时使用是携带String值; 该类型的其余部分应该是一堆不变的定义和行为.MessageField的每个子类都应该是一组定义类型的常量最终成员,如果需要,还可以覆盖其他行为方法.
例如:
public abstract class MessageField {
//whatever needs to go here to make this work
//methods that define behavior
//e.g. public int getFieldId() { return fieldId; }
}
public class TypeOne extends MessageField {
public final int fieldId = 1; //type defining member
public final String tag = "->"; //type-defining member
public String fieldValue; //freely settable/gettable
//change any behavior if necessary
}
public class TypeTwo extends MessageField {
public final int fieldId = 2;
public final String tag …Run Code Online (Sandbox Code Playgroud) 我有一些像这样的代码:
if (input.equals("north") || input.equals("n")) { direction = Cardinals.NORTH; }
Run Code Online (Sandbox Code Playgroud)
是否有任何方法可以使用更简洁的语法,如下所示:
if (input.equals("north" || "n") { direction = Cardinals.NORTH; }
Run Code Online (Sandbox Code Playgroud)
我知道这不起作用,但我希望有一些相同的东西?
java ×2
oracle ×2
sql ×2
equals ×1
filter ×1
final ×1
inheritance ×1
optimization ×1
syntax ×1
union-all ×1