Constructing queries

Using the correct query populates your schedule with relevant data. When you create a query for a schedule, you ensure that you are scheduling precisely the work records that you want to schedule.

You can use the Advanced Search feature in the Changes application to construct a query, or you can type the query directly in the Work Queries section of the Graphical Scheduling application.

When you use the Advanced Search feature, you can do a query by example on the field combinations of interest. After you execute the query, you can see and modify the SQL statement in the Where Clause window, which is available from the Advanced Search menu.

The following examples are common queries that you might use for a Change schedule:

  • All work orders scheduled for a two week period
    ((woclass = 'WORKORDER' or woclass = 'ACTIVITY') and schedstart <= '2010-04-16 09:08:24.000' 
    and historyflag = 0 and siteid = 'BEDFORD' and istask = 0 and schedstart >= '2010-04-05 09:08:04.000' )
  • All work orders that a specific user owns, and are approved or in progress
    owner = (select personid from person where personid = (select personid from maxuser 
    where userid = 'WILSON' )) and status in ('APPR','INPRG') 
    Note that the attribute owner can just as easily be supervisor or lead, or any field that resolves to a person id.
  • All work orders that are scheduled for this week
    ((woclass = 'WORKORDER' or woclass = 'ACTIVITY') and historyflag = 0 and siteid = 'BEDFORD' 
    and istask = 0 and schedstart >= sysdate and schedstart <= (sysdate + 7))
  • All work orders targeted to be complete that are not (backlog)
    ((woclass = 'WORKORDER' or woclass = 'ACTIVITY') and historyflag = 0 and siteid = 'BEDFORD' 
    and istask = 0 and targcompdate <= sysdate and status != 'COMP')
  • All in progress work for a group of assets with a similar prefix, found anywhere on a work order (as the primary asset or an entry in the Multiple Assets, Locations, and CIs table window)
    ((woclass = 'WORKORDER' or woclass = 'ACTIVITY') and status = ‘INPRG' 
    and historyflag = 0 and siteid = 'BEDFORD' and istask = 0) and 
    (exists (select 1 from maximo.multiassetlocci 
    where ((assetnum like 'A80%')) and (recordkey=workorder.wonum and 
    recordclass=workorder.woclass and worksiteid=workorder.siteid)))