t-sql question

  • Hello everybody,

    Is there a way in t-sql or maybe just standard sql to make it select the first value equal to or lower than a given number, and only that one value.

    for example if u had a column of times of the day where transactions took place and you wanted the first value equal to or lower than 12:05:30

    many thanks,

  • If you want the highest that fits the criteria:

    select max(columnName) from table

    where transactionDate <= whateverYouAreCompaingTo

    If you want the first that fits the criteria:

    select top 1 * from table

    where transactionDate <= whateverYouAreCompaingTo

  • it works!

    thank you very much!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply