sweeeeeet
sweeeeeet

Reputation: 1819

auto increment variable in bigquery

I have a table in google bigquery of the form:

id      value
798     <val>
879     <val>
774     <val>
23      <val>

And I want to build a table of the form:

id    value    int_var
798   <val>    1
879   <val>    2
774   <val>    3
23    <val>    4

where the variable int_var is a simple incremental variable. Can someone help me?

Upvotes: 2

Views: 5503

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172994

SELECT 
  id, 
  value, 
  ROW_NUMBER() OVER() AS int_var
FROM YourTable

Upvotes: 4

Related Questions