SQL Server Performance

Referral Nightmare

Discussion in 'SQL Server 2008 General Developer Questions' started by 99jsayer, Jan 28, 2014.

  1. 99jsayer New Member



    Hello Guys,

    I am somewhat new to SQL. I really need some help with the following query. I have three tables like so:

    tblclient
    perid
    name
    dob

    tblreferral
    refid
    type
    info
    commments

    tblreferralaction
    refactid
    status (allocate, nfa, closed)
    status date

    I need to get the list of referrals, per client, in chronological order using the dates from the referralaction table. A allocations status will be given once a referral is open. A status of NFA or Closed means that referral is closed.
    A client can have many referrals, i need to identify the current one and have the others with their open and closed dates.
    I have tried pivoting the data and just cannot get it to work due to the various dates following on.

    Please can someone help?!

    Thanks in advanced!

    Kind Regards
    Jonathan

Share This Page