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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql query help needed

Author  Topic 

vivek.verma111
Starting Member

6 Posts

Posted - 2010-09-09 : 10:25:33
I have 3 sql tables

Patients:

PatientID(varchar), PatientName(varchar), BPM_ID(varchar),WM_ID(varchar)
values:

2020211, XXXYYY, Philips001, ANDINS001

2002012, YDHHHH, Philips002, ANDINS002


BPMReadings:

BPM_ID(varchar), TimeStmp (datetime), BP(int)
Values:

Philips001, 09/09/2010 10:15:11, 150
Philips001, 09/09/2010 11:11:01, 152
Philips001, 08/09/2010 11:12:22, 148
Philips001, 07/09/2010 18:12:22, 147
Philips002, 09/08/2010 10:10:11, 130
etc etc


WMReadings:

WM_ID(varchar), WTimeStmp (datetime), Weight(float)

Values:

ANDINS001, 09/09/2010 09:15:11, 98
ANDINS001, 08/09/2010 10:15:11, 98.2
ANDINS001, 05/09/2010 17:14:11, 98.8
ANDINS002, 09/09/2010 12:15:11, 85
ANDINS002, 08/09/2010 18:15:11, 85.4





Need result like this:

suppose query parameter is @PatientID

if @PatientID='2020211'

Query result:

Date Time BP Time Weight

09/09/2010 10:15:11 150 09:15:11 98

09/09/2010 11:11:01 152 Null Null

08/09/2010 11:12:22 148 10:15:11 98.2

07/09/2010 18:12:22 147 Null Null

05/09/2010 Null Null 17:14:11 98.8

Is it possible to achieve this result using sql query?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-09-09 : 10:26:21
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=149926
Go to Top of Page
   

- Advertisement -