1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

Need a query to run reports the past two hours

Discussion in 'SQL - Questions and Answers' started by sql_question31, Jul 25, 2009.

  1. sql_question31 New Member

    Hi,

    I need help in writing a simple SQL query to run reports for the past two hours. I realize if I use the following, I can get the past two hours.

    SELECT DATEADD(HOUR, -2, GETDATE())AS [TwoHoursAgo]

    How do you use the result of this in my next statements? These are the rest of the statements?

    select column a, column b, column c
    from nt_table
    where timestamp > (This is where I want to use the result of the first querty. So if I can use the result of what ever resulting number I get above from the first query , my report will run the for the past two hours. How do I define this folowing "where timestamp >" .

    Any help is greatly appreciated.

    Thanks,

    SQL newbie

Share This Page