Skip to Main Content

Oracle Database Discussions

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!

sql query Inner Join

451784Sep 8 2008 — edited Sep 8 2008
Hi All,
A strange situation for me, probably the first time I have come across this, thats y I m searching for a solution.
Consider Table below.

Table A
AGENT_ID, SUP_ID, AREA, P1, P2, P3.

A1001 S1 A1
A1002 S1 A1
A1003 S1 A1
A1004 S3 A1
A1005 S4 A3
A1006 S3 A1
A1007 S2 A2
A1008 S2 A2
A1009 S2 A2


The table shows that we have fixed number of SUP_ID i.e s1-s4= 4. and from these 4 SUP_ID , the values are assigned to different agents....
The Area is also repetitive, but does not depend on AGENT ID.

The query = User wants to gets the distinct SUP ID with the values P1,p2,p3,p4 and Area against each of the SUP_ID.

" select distinct (SUP_ID), area_id,p1,p2,p3 from Table A. "
The result should be only 4 rows , but the actual number of rows are much greater than 4, and less than 9.
Why is this????

Another query

"Select disticnt (A.sup_id),a1.area_id,a1.p1,a1.p2,a1.p3
from TABLE A where a.sup_id=a1.sup_id "

This should yield the correct records i.e 4 ,, but this is not working as well.

May i know what the hell is the issue.

How can I extract distinct sup_id and the rest of the values against each .

Regards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 6 2008
Added on Sep 8 2008
3 comments
404 views