Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 4th, 2005, 12:48 PM
aarnone aarnone is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 1 aarnone User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 50 sec
Reputation Power: 0
sql help

I have this query below which works but I need to modify it so I get a more precise result:

Select a1.JOB_SCHED_ID,
a1.JOB_SCHED_NAME, a1.JOB_ENABLED_FLAG, a1.JOB_SCHED_TYPE,
a1.ONE_TIME_FLAG, a1.ONE_TIME_DATETIME,
a1.DAILY_FLAG, a1.DAILY_FROM_TIME, a1.DAILY_TO_TIME, a1.DAILY_FREQUENCY_IN_MIN,
a1.WEEKLY_FLAG, a1.WEEKLY_TIME, a1.WEEKLY_DAYOFWEEK,
a1.MONTHLY_FLAG, a1.MONTHLY_DAYOFMONTH, a1.MONTHLY_TIME,
a1.EMAIL_ON_ERROR, a1.EMAIL_ON_SUCCESS, a1.DATE_DELETED,
a2.JOB_LOG_ID, a2.JOB_SCHED_ID, a2.START_DATE, a2.END_DATE, a2.JOB_STATUS_ID,
a2.FAILED_JOB_STEP_NUMBER, a2.DATE_DELETED, a2.ERROR_MESSAGE, a3.JOB_STATUS_DESC,
a4.JOB_STEP_ID, a4.JOB_STEP_NAME, a5.REQUEST_ID, a5.DATETIME_PROCESSED
from SCHDLR_JOB_TBL a1, SCHDLR_JOB_LOG_TBL a2, SCHDLR_STATUS_TBL a3, SCHDLR_JOB_STEP_TBL a4, SCHDLR_JOB_REQUEST_TBL a5
where a1.JOB_SCHED_ID = a2.JOB_SCHED_ID (+)
and a2.JOB_STATUS_ID = a3.JOB_STATUS_ID (+)
and a1.JOB_SCHED_ID = a4.JOB_SCHED_ID AND a4.DATE_DELETED is null
and a1.JOB_SCHED_ID = a5.JOB_SCHED_ID (+)

The problem with the above query is that the schdlr_job_log_tbl can contain one to many entries for each job record in the schdlr_job_tbl, so what I need to do is only select the latest record from the log_tbl based on the end_date. Now I know how to do this with the following query, but I dont know how to incorporate the two.

SELECT x.job_sched_id, X.END FROM (SELECT JOB_SCHED_ID, MAX(NVL(END_DATE,SYSDATE)) "END" FROM SCHDLR_JOB_LOG_TBL GROUP BY JOB_SCHED_ID) X
WHERE x.job_sched_id=1

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > sql help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT