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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Top 1 from a multiple table statement

Status
Not open for further replies.

AndyFreeman

IS-IT--Management
Mar 22, 2004
70
GB
Within the below statement, how do i select "Top 1" record.
If i try place top 1 in after my select it errors asking for the FROM details

Thanks 4 any help


"select request.REQUEST_ID, place.name, request_event_eta.EVENT_DT c2 , to_char(request_event_eta.EVENT_TM, 'HH24:MI') c3 , request_event_arrv.EVENT_DT c4 , to_char(request_event_arrv.EVENT_TM, 'HH24:MI') c5 , request_event_eta.PERSON_ID_TO c6 , {fn CONCAT({fn CONCAT(person.FIRST_NAME,' ')},person.NAME)} c7 " & _
"from OU_DBA.PERSON person, OU_DBA.REQUEST request, OU_DBA.REQUEST_EVENT request_event_eta, OU_DBA.REQUEST_EVENT request_event_arrv, OU_DBA.VISIT visit, place " & _
"where request.place_id = place.place_id and request.REQUEST_ID = request_event_eta.REQUEST_ID(+) and 'MC-INT' = request_event_eta.EVENT_TYPE(+) and request.REQUEST_ID = request_event_arrv.REQUEST_ID(+) and 'ARRV-1' = request_event_arrv.EVENT_TYPE(+) and request.REQUEST_ID = visit.REQUEST_ID(+) and request_event_eta.PERSON_ID_TO = person.PERSON_ID and request_event_eta.EVENT_DT = to_date('" & Search_date & "', 'YYYY-MM-DD HH24:MI:SS') " & _
"order by c6 asc , c3 asc
 
It doesn't look like your From area has any relationships. I believe that might point you in the correct direction.

Hope everyone is having a great day!

Thanks - Jennifer
 
this statment on its own works ok for me, and returns all restus as expected.

I am just looking to be a bit more specific on my data
 
I understand that the query works as is but to utilize some of the SQL functions, I believe that joins in the from area might allow more.

It was just an idea... hope someone else can help.

Hope everyone is having a great day!

Thanks - Jennifer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top