-3

in Vertica DB, I need to build a query selecting all rows with the timestamp within the past period of two hours from now. This doesn't work, however:

select * from device_health_1
where timeframe >= current_timestamp - interval 2 hour  

NOW() doesn't seem to work, either.
Would appreciate suggestions. Thanks!

Yan
  • 77
  • 4
  • 3
    what database you are using? tag the actual database engine you are sing, – eshirvana Dec 30 '21 at 19:12
  • 1
    DBVisualizer is a SQL client that can connect to many different database products and is irrelevant for this question. (Note that the query in your question is non-standard SQL) –  Dec 30 '21 at 19:39
  • Sorry, Vertica DB – Yan Dec 30 '21 at 20:26
  • What "doesn't work" actually means? If your computer accidentally turned off, then it "doesn't work" also, but has nothing about the SQL code. Please provide sample data and desired output along with your current output and description, why do you consider it wrong – astentx Dec 30 '21 at 22:55

1 Answers1

0
SELECT *
FROM device_health_1
WHERE timeframe >= current_timestamp - interval '2 hour'  

The error was missing single quotes. Working now, thanks!

Elikill58
  • 4,050
  • 24
  • 23
  • 45
Yan
  • 77
  • 4