在Oracle的同一张表中比较两行 [英] to compare two rows in the same table in oracle

查看:101
本文介绍了在Oracle的同一张表中比较两行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
需要您的帮助.我只想要具有相同cno和相同类型且状态与以下不同的记录.请在下面查看我所需的结果.我尝试了自我加入,但没有成功.
Cno. Csubno.键入Rid rdate status
111111-001 A 1234 2011年11月1日DischargeReady
111111-002 A 1235 11/1/2011放电
222 222-001 B 1444 12/1/2011待审核
222 222-002 B 1444 2011/12/1待审核
必需的结果.
Cno. Csubno.键入Rid rdate status
111111-001 A 1234 2011年11月1日DischargeReady
111111-002 A 1235 11/1/2011放电
在此先感谢.

Hi EveryOne.
Need your help on this. I only want the records which has same cno and same type and different status from following.Please see my required result below. I tried self join but it didn''t work.
Cno. Csubno. Type Rid rdate status
111 111-001 A 1234 11/1/2011 DischargeReady
111 111-002 A 1235 11/1/2011 Discharged
222 222-001 B 1444 12/1/2011 Pending
222 222-002 B 1444 12/1/2011 Pending
Required Result.
Cno. Csubno. Type Rid rdate status
111 111-001 A 1234 11/1/2011 DischargeReady
111 111-002 A 1235 11/1/2011 Discharged
Thanks in advance.

推荐答案

像这样吗?

Something like this?

SELECT
    [Cno.]
    [Csubno.]
    Type
    Rid
    rdate
    status
FROM {Your_Table_Name}
WHERE
    [Cno.] = [Cno.]
    AND
    [Csubno.] = [Csubno.]
    AND
    status <> status


这篇关于在Oracle的同一张表中比较两行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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