Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Arnold
Starting Member
5 Posts |
Posted - 2005-02-18 : 18:20:13
|
| Hi, all, I have a database full of patient names, their blood pressures and the dates the measurements were taken. How do I select only those patients with at least TWO measurements greater than 134 within the past year?VALUE1 is the blood pressure measurement; VDATE is the date the measurement was taken. This is the WHERE clause I have so far:WHERE (dbo.VITALS.VALUE1 > 134) AND (dbo.VITALS.VDATE > GETDATE() - 365) Thanks. |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2005-02-18 : 18:38:25
|
Maybe something like:select v.*from vitals vjoin( select patientid from vitals where vdate > ( getdate()-365 ) and value1 > 134 group by patientid having count(value1) >= 2) d on d.patientid = v.patientid |
 |
|
|
Arnold
Starting Member
5 Posts |
Posted - 2005-02-22 : 18:51:44
|
| That worked. Thanks, ehorn. |
 |
|
|
|
|
|