0
votes

I am returning a set of values in a bigquery select statement like this

enter image description here

I need to add a compute field Utlization for each row like this formulae (end_time - start_time)*cores Utilization

This time format is in UTC so I am not sure how to do this , I want to do this in the select statement itself. I am new to BigQuery. Kindly Help . Thanks

1

1 Answers

1
votes

You need to use TIMESTAMP_DIFF function in standard SQL.

In your particular case the query would be something like

SELECT TIMESTAMP_DIFF(end_time , start_time , second)*cores  as Utilization 
FROM <yourtable>

Take into consideration that you can change the time unit of the result and you should change it to fit your needs. I inserted second but you can use microsecond, millisecond, second, minute, hour or day.