sqlselecttop-n

Finding one value in relation to the value of another column


I've got a table that looks a bit like this

enter image description here

What I want to do is find the pressure value of the earliest Start_Time

So in this case I want the value "5"

How can I do this? I'm not sure of how to relate 2 values this way


Solution

  • You want the first value by start_time so sort by start_time and take the first one:

    Select top 1 Pressure, Start_Time  
    From yourTable 
    Order by Start_Time asc