I have an interview questions, Which of the two SQL statements below would be faster? Assume that the table is indexed using the registration_timestamp column. Explain why.
Query 1
SELECT 
  name
FROM 
  user_table
WHERE 
  DATE(DATETIME_ADD(registration_timestamp, INTERVAL 7 HOUR))
         >= DATE(‘2018-01-01’)
  AND 
  DATE(DATETIME_ADD(registration_timestamp, INTERVAL 7 HOUR)) 
         < DATE(‘2019-01-01’) 
Query 2
SELECT 
  name
FROM 
  user_table
WHERE 
  registration_timestamp
>= DATETIME_SUB(‘2018-01-01’, INTERVAL 7 HOUR)
  AND 
  registration_timestamp
< DATETIME_SUB(‘2019-01-01’, INTERVAL 7 HOUR) 
i'm using sql and bigquery but syntax did not correct. Any idea ?
 
     
     
    