Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8497

Help with an SQL Expression - Return field value where Datetime is Min or First datetime

$
0
0

Hello,

 

I'm extracting results for a patient population.

 

I have 6 SQL expressions that pull back the first date for specific procedures or Medications being ordered.

 

These Expressions work perfect - One of the expressions return the first time a lab was ordered.

I'm using SQL that return

Min(OrderDatetime)

From OrderTable

Where

LABCode = XXX

 

I've now been ask to return the value of this lab result.

 

Question: How do I write an SQL expression that return the Lab value of the Min(OrderDatetime)

 

Example Data

 

PATID* LABID * OrderDatetime * ResultValue

 

Pat1*133 * 12/12/2013 11:00:pm * 77

Pat1*145 * 12/12/2013 11:45:pm * 45

Pat1*147 * 12/13/2013 12:10:AM * 78

 

I was to return 77

 

Thanks

Steve


Viewing all articles
Browse latest Browse all 8497

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>