如何从下面的oracle sql查询中获得不同的结果?

时间:2016-04-21 14:08:07

标签: sql oracle plsql oracle-sqldeveloper

SELECT  FCR.FCR_ID,
        FCR.FCR_TITLE FCR_TITLE,
        to_char(FCR.FCR_DATE_SUB, 'fmDD Mon YYYY') DATEIN 
FROM    PMP_SCRIPT        FCR,
        PMP_SCRIPT_PART CST, 
        PMP_USER              USR,
        PMP_SCRIPT_EVENTS PST
WHERE   CST.CST_ROLE  = 'MANAGER'   and 
        CST.CST_STATUS    = 'ADDED'   and 
        CST.CST_USR_ID    = 1573752923320092       and 
        PST.PST_EVENTTYPE = 'ONREVIEW' and 
        PST.PST_FCR_ID    = CST.CST_FCR_ID     and  
        PST.PST_USR_ID    = USR.USR_ID       and   
        PST.PST_FCR_ID    = FCR.FCR_ID  
ORDER  BY FCR.FCR_DATE_CREATED;     

我得到以下结果

        PAGES               TITLE                           DATEIN
        6746061995031488    complex ecosystem               20 Oct 2014
        1057034726101865    mutated seabed cores            20 Feb 2013
        1057034726101865    mutated seabed cores            20 Feb 2013
        2174332191071984    Cheomtherapy Structure design   09 Jan 2013
        6541320181289621    Earthquake  Epicenter           21 Dec 2013
        6541320181289621    Earthquake  Epicenter           21 Dec 2014
        6541320181289621    Earthquake  Epicenter           21 Dec 2013
        6541320181289621    Earthquake  Epicenter           21 Dec 2013
        6541320181289621    Earthquake  Epicenter           21 Dec 2013
        6541320181289621    Earthquake  Epicenter           21 Dec 2013
        6541320181289621    Earthquake  Epicenter           21 Dec 2013

但我希望得到所有独特的结果,有人可以帮助我 我已尝试使用distinct关键字,但查询提供了“not selection expression

1 个答案:

答案 0 :(得分:1)

您可以尝试使用不同的内联查询。也许这会对你有帮助。

SELECT DISTINCT A.*
FROM
  (SELECT FCR.FCR_ID,
    FCR.FCR_TITLE FCR_TITLE,
    TO_CHAR(FCR.FCR_DATE_SUB, 'fmDD Mon YYYY') DATEIN
  FROM PMP_SCRIPT FCR,
    PMP_SCRIPT_PART CST,
    PMP_USER USR,
    PMP_SCRIPT_EVENTS PST
  WHERE CST.CST_ROLE    = 'MANAGER'
  AND CST.CST_STATUS    = 'ADDED'
  AND CST.CST_USR_ID    = 1573752923320092
  AND PST.PST_EVENTTYPE = 'ONREVIEW'
  AND PST.PST_FCR_ID    = CST.CST_FCR_ID
  AND PST.PST_USR_ID    = USR.USR_ID
  AND PST.PST_FCR_ID    = FCR.FCR_ID
  ORDER BY FCR.FCR_DATE_CREATED
  )A ;