Query to find all jobs that work started on a certain day-VBForums
Results 1 to 3 of 3

Thread: Query to find all jobs that work started on a certain day

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    313

    Query to find all jobs that work started on a certain day

    I have a table containing jobs and dates that work was done on these jobs:

    Job Date Work Done
    A 01 Jan 2013
    A 02 Jan 2013
    A 03 Jan 2013
    B 02 Jan 2013
    B 03 Jan 2013
    C 03 Jan 2013

    I want to know which jobs started on say 02 Jan 2013 - the answer is job 'B'.

    What would be the query for this?

    Thanks.

  2. #2
    Junior Member
    Join Date
    Jan 2013
    Posts
    30

    Re: Query to find all jobs that work started on a certain day

    SELECT job FROM tableName WHERE [date work done] = #2/1/2013#

  3. #3
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    3,476

    Re: Query to find all jobs that work started on a certain day

    Am I right in saying that you don't want Job A because that actually started on the 1st of Jan? I.E. you want jobs whose lowest date is 2/1?

    If so I think you actually want this:-
    Select Job
    From MyTable
    Group By Job
    Having MIN([Date Work Done]) = '2013-01-02'


    Be warned, though, that doesn't account for non-contiguous date ranges. So a job that was worked on the 2nd, 3rd, 6th and 7th would be returned if you query for the 2nd but not the 6th.
    When one of my minions says, "Hey, he's just one guy, what can he do?" I say "This"... and shoot them.

    The problem with putting your lair in a volcano is keeping your robot army from melting.

    I know that the human being and the fish can coexist peacefully - George Bush

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.