我想知道如何使用类似以下的查询将活动ID返回到父查询以删除父记录集。这里的问题是使用这个组或不同我找不到办法。
我将使用所有group by字段来确定唯一记录。但是,我只需要使用select min(status.effective_date)
的记录查询返回正确的日期值,但我无法仅使用该日期值将其链接回父项活动记录。
select min(status.effective_date)
from accounts
, address
, activity
, status
where accounts.par_row_id = activity.account_id
and address.row_id = activity.address_id
and status.par_row_id = activity.status_id
and account.name = 'xyz'
group by account.name, address.addr, address.ADDR_LINE_2, address.ADDR_LINE_3
, address.ADDR_LINE_4, address.CITY, address.COUNTRY, address.X_STATE
, address.ZIPCODE
答案 0 :(得分:0)
您应该尝试此查询:
select min(activity.row_id) keep(dense_rank first order by status.effective_date) as activity_id
from accounts
, address
, activity
, status
where accounts.par_row_id = activity.account_id
and address.row_id = activity.address_id
and status.par_row_id = activity.status_id
and accounts.name = 'xyz'
group by accounts.name, address.addr, address.ADDR_LINE_2, address.ADDR_LINE_3
, address.addr_line_4, address.city, address.country, address.x_state
, address.ZIPCODE;