Answer for:

how to write the full statement?

Message 6 of 6

View entire thread
1 Votes
dcolbert Contributor

This seems like it would do the trick:

select patient_identification_number
, CONVERT(decimal(18,1), SUM(RBC) / COUNT(RBC)) as AVG_RBC
, CONVERT(decimal(18,1), SUM(WBC) / COUNT(WBC)) as AVG_WBC
, CONVERT(decimal(18,1), SUM(PLT) / COUNT(PLT)) as AVG_PLT
, Lab_Result_Date
from patient_info_table
where Lab_Result_Date >= '01/01/2005' and Lab_Result_Date < '07/01/2005'
and WBC > 9
group by patient_identification_number

But if you don't understand why - you probably shouldn't submit it as your answer - because there are already enough people like that in the industry as it is, anyhow.

Props to an app/SQL developer I know for throwing this together for me.

And really - here is my point... I'm not even *remotely* a coder or developer. If the logic required to make this statement in SQL, Java, C++, Visual Basic or any other development or scripting language escapes you - you might be barking up the wrong tree in your career development. Don't chase after coding because you think it'll be good money if you don't have the mindset for it. But if you can read the code above and the light goes on for you and you can at least understand in an abstract sense what is going on there... then by all means keep on.