如何在连接中选择单行?

时间:2015-09-11 09:21:28

标签: sql oracle left-join

SELECT 
    MYSCHEME.C.ID as CELLID, 
    MYSCHEME.C.NUM as CELLNUM, 
    MYSCHEME.C.UND_ID as U_ID, 
    MYSCHEME.U.SERIAL as SERIAL, 
    MYSCHEME.U.AMS_NETID as AMSID,
    MYSCHEME.U.IP_ADDRESS as IP_ADDRESS,
    MYSCHEME.U.MAC_ADDRESS as MAC_ADDRESS,
    MYSCHEME.IDARESULTS.ID as IDAID
    FROM 
    MYSCHEME.C
    LEFT OUTER JOIN MYSCHEME.U ON MYSCHEME.C.U_ID = MYSCHEME.U.ID 
    LEFT OUTER JOIN MYSCHEME.IDARESULTS ON MYSCHEME.C.ID = MYSCHEME.IDARESULTS.CELLID
    WHERE 
    MYSCHEME.C.SA = 1;

此处IDARESULTS表格中包含ACTION_DATETIMESTAMP

我需要修改上面的查询,因此LEFT OUTER JOIN MYSCHEME.IDARESULTS ON MYSCHEME.C.ID = MYSCHEME.IDARESULTS.CELLID只返回1条记录,该记录具有最近的时间戳。我怎样才能实现它?

0 个答案:

没有答案