I have 2 SQL server tables
1. Bloodtest containing a list for valid bloodtests (bloodtestNumber) and descriptions (BloodWorkx)
2 PatientBloodtest containing the results captured for a specific patient (PatientBloodWorx)
Users capture blood test results at different times and they do not always capture all the bloodtests. ALL I want to do is to display the last blood test results captured for the patient in a gridview using this query
SELECT BloodWorx.BldTestName, PatientBloodWorx.membershipNumber,
PatientBloodWorx.BeneficiaryCode, MAX(PatientBloodWorx.BloodTestDate) AS LastOfbloodtestdate, MAX(PatientBloodWorx.BloodTestReceiveDate) AS LastOfBLOoDTESTRECEIVEDATE, MAX(PatientBloodWorx.BloodResult)
AS LastOfBloodresult FROM BloodWorx LEFT JOIN
PatientBloodWorx ON BloodWorx.BldNumber = PatientBloodWorx.BloodTest
GROUP BY BloodWorx.BldTestName, PatientBloodWorx.membershipNumber,
PatientBloodWorx.BeneficiaryCode, BloodWorx.BldNumber
HAVING (PatientBloodWorx.membershipNumber = @membershipNumber) AND (PatientBloodWorx.BeneficiaryCode = @BeneficiaryCode)
Can someone help?
1. Bloodtest containing a list for valid bloodtests (bloodtestNumber) and descriptions (BloodWorkx)
2 PatientBloodtest containing the results captured for a specific patient (PatientBloodWorx)
Users capture blood test results at different times and they do not always capture all the bloodtests. ALL I want to do is to display the last blood test results captured for the patient in a gridview using this query
SELECT BloodWorx.BldTestName, PatientBloodWorx.membershipNumber,
PatientBloodWorx.BeneficiaryCode, MAX(PatientBloodWorx.BloodTestDate) AS LastOfbloodtestdate, MAX(PatientBloodWorx.BloodTestReceiveDate) AS LastOfBLOoDTESTRECEIVEDATE, MAX(PatientBloodWorx.BloodResult)
AS LastOfBloodresult FROM BloodWorx LEFT JOIN
PatientBloodWorx ON BloodWorx.BldNumber = PatientBloodWorx.BloodTest
GROUP BY BloodWorx.BldTestName, PatientBloodWorx.membershipNumber,
PatientBloodWorx.BeneficiaryCode, BloodWorx.BldNumber
HAVING (PatientBloodWorx.membershipNumber = @membershipNumber) AND (PatientBloodWorx.BeneficiaryCode = @BeneficiaryCode)
Can someone help?