【发布时间】:2012-06-26 10:36:27
【问题描述】:
TABLEA
LOGIN_ID ,COL1,COL2
TABLEB
LOGIN_ID, RESIGN_DATE, LAST_DATE, STATUS
我想从 TABLEA 中为特定 login_id 选择 login_id、resign_date 和 last_date
Login_ID 是 TABLEA 和 TABLEB 之间的链接。在 TABLEB 中,同一个 login_id 可以有多个记录。我想选择满足以下条件的resign_date和last_date。
1)if status is null for at least one of them
it should identify that entry whose status is null
System populate the resign_date and last_date of this entry
2)if status is ‘Y’ for all of them
resign_date = ’12/31/2050’
last_date = ’12/31/2050’
3)If no entry in TABLEB
resign_date = null
last_date = null
如何为此编写一个 oracle sql 查询?
【问题讨论】:
-
:系统将如何填充空输入的日期...它将是什么日期?我问的是第一个条件
-
如果 TABLEB 行的状态为空怎么办?
-
@GauravSoni 在这种情况下,我应该获得状态为空的条目的 resign_date 和 last_date ..
-
@TonyAndrews 只有一行状态为空.. 我忘了提..
-
@Ollie 我尝试使用左连接来编写它......我无法让它工作......