Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

this is an sql what is the best rep

Status
Not open for further replies.

raji96

Programmer
Aug 7, 2001
64
US
this is an sql what is the best replacement for "!="



SELECT DISTINCT A.NUMBER,
A.FLAG, A.FIRST,
A.MIDDLE, A.SUFFIX,
A.LAST, A.DESIGN,
A.CODE, A.SENIOROITY,
A.REMARK, B.GROUPCODE,
B.SUBGROUPCODE FROM PROFILE A,
DIVERT B, IDENTITY C,
SUBGROUPS S,SUBGROUPE E
WHERE C.LOGINID= 'Fddadadadadad'
AND A.ID =C.ID
AND A.GROUPID = B.GROUPID
AND B.ID=S.ID
AND B.GROUPCODE(+)=S.GROUPCODE
AND B.SUBGROUPCODE !=S.SUBGROUPCODE
AND B.ID=E.ID
AND B.SVB024_GROUPCODE(+)=E.SVB024_GROUPCODE
AND B.SUBGROUPCODE != S.SUBGROUPCODE
 
... Or use 'B.SUBGROUPCODE NOT IN (S.SUBGROUPCODE)' in the event that S.SUBGROUPCODE is a list or has multiple values.
 
i'm not sure why you want to get rid of the !=

Also, you outer join b to s
AND B.GROUPCODE(+)=S.GROUPCODE

The operators != and <> behave strangely with null. since you have &quot;b.subgroupcode != s.subgroupcode&quot; I would suggest doing &quot;b.subgroupcode != nvl(s.subgroupcode,0)&quot; where 0 is not a valid subgroupcode.

Otherwise your SQL appears fine. If this query is running slowly because of the != you may try passing a hint to your SQL statement. If the query was returning no data with the !=, then try to use the NVL, and that will probably fix that problem.

Hope something in here helps.


.
.. Eat, think and be merry .
... ....................... .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top