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
    350

    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
    7,900

    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.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

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



Click Here to Expand Forum to Full Width