Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2014

    Unanswered: date difference problems

    I have two tables:
    clients containing clientid, forename, surname
    advice containing adviceid, date, clientid

    A client could come any number of times for advice.

    I want to extract:
    the number of clients who have received advice between two dates - date1 and date2 (I can do this)
    the number of people who are ‘new’ i.e. the ones who last received advice 12 months or more before date1

    It is this second one that I can’t do.

    Can anyone help?

  2. #2
    Join Date
    Dec 2014
    Hi Gabucknall,
    You should try the following (I hope it helps):

    select count(a1.clientid) as 'New Patients'
    from advice a1
    join advice a2
    on a1.clientid=a2.clientid
    and datediff(, > '365'

Posting Permissions

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