问题描述
我有下表:
我想创建这样的视图:
对于两个表中共同的
fund_isin
字段值,检查member_ratio
字段的member_descr = 'O'
并获取所有表中的 fund_isin 行,其中member_ratio
字段值较低.对于member_descr = 'O'
,如果IS_ID_TST
表中的member_ratio
对于任何fund_isin
小于 0,则总是取IS_ID_TST
表中的所有数据(在这种情况下,我们不需要比较IS_ID
表中的数据,因为成员比例低)
for common
fund_isin
field value from both tables, check themember_ratio
field formember_descr = 'O'
and take all the rows for fund_isin from table wheremember_ratio
field value is low. Formember_descr = 'O'
, if themember_ratio
inIS_ID_TST
table is less than 0 for anyfund_isin
then always take all the data fromIS_ID_TST
table(in this case we dont need to compare data fromIS_ID
table for low member ratio)
如果 fund_isin
存在于一个表中但不存在于另一个表中,则获取所有这些行(双向).
if the fund_isin
exist in one table but not in another then take all those rows(bidirectional).
对于所有其他 fund_isin,仅从表 IS_ID_TST
表中获取所有这些行(这可能涵盖第 1 点和第 2 点)
for all the other fund_isin, take all those rows only from table IS_ID_TST
table(this might cover in point 1 and 2 )
推荐答案
您能否检查以下查询,我已经在 with
子句中制作了所有案例,然后将其结合起来.
Could you check following query, I have made all cases within with
clause and then make union out of it.
- 通过聊天与 OP 讨论和澄清
我们不再需要 full join
并且通过根据每种情况访问表来重写它.
We do not need full join
any more and by accessing the table per each case it is re-written.
这篇关于创建 Oracle 视图以根据条件比较数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!