BigQuery - running a query with two different sections

I am trying to run a query with two different sections. The difference is that one section is sorted and the other is not (the query below just illustrates the problem, it doesn't make sense)

SELECT 
  repository.forks forks,
  repository.fork fork,
  row_number() over (partition by repository.url order by repository.created_at ) r,
  count (repository.fork) over (partition by repository.url) cnt,
FROM [publicdata:samples.github_nested] LIMIT 1000

      

When I run the query above, I get a strange error: Fork field not found; did you mean the "plug"?

When you remove one of the window functions, the query works fine.

Can I run a query with two different sections?

+3


source to share


1 answer


How to write:



SELECT 
  repository.forks ,
  repository.fork ,
  row_number() over (partition by repository.url order by repository.created_at ) r,
  count (repository.fork) over (partition by repository.url) cnt,
FROM [publicdata:samples.github_nested] LIMIT 1000

      

+3


source







All Articles