Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Oracle distinct select issue

Oracle distinct select issue

From: <mastermind148_at_gmail.com>
Date: 5 Aug 2006 15:20:09 -0700
Message-ID: <1154816409.861632.243480@i42g2000cwa.googlegroups.com>


Hello.
I have one problem with oracle select. Let have this simplified select select * from
(

  select

      itms.CIT_SEARCHCODE searchcode,
      inc.INC_ID id
  from
      servicedesk.itsm_incidents inc,
      servicedesk.ITSM_CONFIGURATION_ITEMS itms
  where
      (inc.INC_CIT_OID = itms.CIT_OID)

  ORDER BY inc.INC_ID DESC
)
where ROWNUM<=20

This select dumps 20 rows. But, I want to select 20 rows with unique searchcode. So i tried something like this select distinct(searchcode),id from
(

  select

      itms.CIT_SEARCHCODE searchcode,
      inc.INC_ID id
  from
      servicedesk.itsm_incidents inc,
      servicedesk.ITSM_CONFIGURATION_ITEMS itms
  where
      (inc.INC_CIT_OID = itms.CIT_OID)

  ORDER BY inc.INC_ID DESC
)
where ROWNUM<=20
But i didnt work. Select dumps 20 rows but without distinct searchcode. then i tried to select just the searchcode column without id. select distinct(searchcode) from
(

  select
      itms.CIT_SEARCHCODE searchcode,
      inc.INC_ID id
  from
      servicedesk.itsm_incidents inc,
      servicedesk.ITSM_CONFIGURATION_ITEMS itms
  where
      (inc.INC_CIT_OID = itms.CIT_OID)

  ORDER BY inc.INC_ID DESC
)
where ROWNUM<=20
this select worked properly. It selects 20 distinct searchcodes. Have anybody any idea how to select 20 rows from that joined tables, by unique searchode?
I will appreciate any help. I got stuck :) Received on Sat Aug 05 2006 - 17:20:09 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US