Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8798889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:11:35+00:00 2026-06-14T00:11:35+00:00

I am trying to pull work orders from jobs based on their dispatch date

  • 0

I am trying to pull work orders from jobs based on their dispatch date to find neglected jobs. I only want the work order with the most recent dispatch date for that job so I can determine how long since it was last dispatched to. However, I do not want to pull any jobs that have null work orders because these are in the process of being dispatched. I tried a ROW_NUMBER statement and then only pulling the top row, but I would need nulls to show up first on the list then the latest date so that didn’t work. The jobs also have a status with them open or closed and the open ones are the ones that are always null Here is the script I have so far:

SELECT DISTINCT

    [O].[Name] AS [Opportunity],
    [O].[Office_Location__c] AS [Office],
    MAX([WO].[saasdisp__Dispatch_Date__c]) AS [MaxDate]

FROM    [Opportunity] AS [O]
    JOIN [saasdisp__Work_Order__c] AS [WO] ON ([O].[Name] = [WO].[OppName__c]
                AND [O].[Id] = [WO].[Opportunity__c])

WHERE   [O].[StageName] = 'In Progress'


GROUP BY    [O].[Name],
            [O].[Office_Location__c]

This is what I’m getting:

Opportunity         Office        MaxDate
Azad, Fariba          LA    2012-11-08 00:00:00.000
Cantrell, Timothy L.  LA    2012-11-07 00:00:00.000
Feiner, Jeffrey       LA    2012-11-06 00:00:00.000
Greasby, Kat          LA    2012-11-06 00:00:00.000

Which is what I need, except that these opportunities actually have open work orders with null dates waiting to be dispatched.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:11:36+00:00Added an answer on June 14, 2026 at 12:11 am

    Add a NOT EXISTS check to your where clause:

    …

    WHERE   [O].[StageName] = 'In Progress'
    
    AND NOT EXISTS (
        SELECT *
        FROM [saasdisp__Work_Order__c] AS [WO2] 
        WHERE [WO2].[saasdisp__Dispatch_Date__c] IS NULL
              AND [O].[Name] = [WO2].[OppName__c]
              AND [O].[Id] = [WO2].[Opportunity__c]
    )
    
    
    GROUP BY    [O].[Name],
                [O].[Office_Location__c]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pull multiple columns from 3 joined tables, but I want
I am trying to pull the top three rows from a database based off
I'm trying to sample from a multinomial in order to pull out elements of
When I pull each leadstatus individually (?leadstatus=New, ?leadstatus=Hot, etc.) they work, but when trying
Just trying to pull off some SMART info from connected Hard Drives on any
I'm trying to pull data from the YouTube API into a local MySQL table.
I am trying to pull a specific set of records from a table called
I am trying to pull an LDAP jpegPhoto attribute from an openLDAP server using
I'm trying to pull a project from git, in particular, this one: https://github.com/pocmo/Yaaic .
I'm trying to pull a username from a sql database to place on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.