Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

count of matching and unmatching rows.

872918Mar 25 2014 — edited Mar 27 2014

Hi all,

i have two tables

EMP1                             EMP2

ID   NAME                    ID      NAME

1     SAM                      1        SAM

2      JOHN                    2        ROCK

3      STEVE                  3        MARK

the queries i need.

QUERY1 :                                                                 QUERY2:                                                     

select 'NAME ' , count(*)                                     select 'NAME ' , count(*)

from EMP1 E1 , EMP2 E2                                   from EMP1 E1 , EMP2 E2

where E1.ID = E2.ID                                            where E1.ID = E2.ID

and E1.NAME = E2.NAME                                  and E1.NAME <> E2.NAME

RESULT:                                                                                  RESULT:                                                                                                                                                         

NAME     COUNT(*)                                                            NAME     COUNT(*)

NAME      1                                                                        NAME      2

But i need a single query or proc that will display the result set as below

NAME_MATCHING  COUNT(*)             NAME_UNMATCHING      COUNT(*)

===============      =========  =================      =========

NAME                            1                      NAME                                 2

Thank you

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2014
Added on Mar 25 2014
7 comments
870 views