[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Simple Query



Hi...
Could anyone tell me what is the difference between these two Query and
why they produce a different result ?
I only want to get the current record from the JOB record.
any help would very appreciated
thanks in advance

regards,
Hartono Sutirman

This one I use alias A in the SubQuery
**************************************
SQL> ED
Wrote file afiedt.buf
  1  SELECT EMPLID, EFFDT
  2  FROM PS_JOB
  3* WHERE EFFDT = (SELECT MAX(A.EFFDT) FROM PS_JOB A WHERE A.EMPLID =
EMPLID)
SQL> /

EMPLID      EFFDT
----------- ---------
680000643   01-OCT-98


This one I use alias A in the main Query
****************************************
SQL> ED
Wrote file afiedt.buf
  1  SELECT A.EMPLID, A.EFFDT
  2  FROM PS_JOB A
  3* WHERE A.EFFDT = (SELECT MAX(EFFDT) FROM PS_JOB WHERE EMPLID =
A.EMPLID)
SQL> /

EMPLID      EFFDT
----------- ---------
130344940   07-AUG-98
680000643   01-OCT-98
T68456789   06-APR-92
680000136   09-AUG-98