Mariana Alves
Mariana Alves

Reputation: 86

Get the last data of my google analytics dataset

I'm trying to get the last table processed with Google Analytics dataset data using this code:

SELECT * FROM TABLE_QUERY(77xx77xx,'table_id CONTAINS "ga_sessions" 
      AND last_modified_time= (Select MAX(last_modified_time) 
                              FROM 77xx77xx.__TABLES__
                              where table_id contains "ga_sessions")'
            )

This not working. The BigQuery interface returns me the following error:

Error: Encountered "" at line 4, column 17.

Can you help me?

Upvotes: 3

Views: 108

Answers (3)

Jordan Tigani
Jordan Tigani

Reputation: 26637

This should work (I think it is what you were getting at in your self-answer, but this shows the complete query):

SELECT *
FROM TABLE_QUERY(77xx77xx,
  'table_id contains "ga_sessions" AND 
  table_id IN (
    SELECT table_id 
    FROM publicdata:samples.__TABLES__
    ORDER BY creation_time DESC 
    LIMIT 1)")

Upvotes: 2

Mariana Alves
Mariana Alves

Reputation: 86

I Found a soluction. Follows:

SELECT table_id AS tabela FROM [77xx77xx.__TABLES__] 
WHERE table_id CONTAINS "ga_sessions_20" ORDER BY tabela DESC LIMIT 1

Upvotes: 3

israel altar
israel altar

Reputation: 1794

Try to use ' instead of ":

 CONTAINS 'ga_sessions'

look at this answer for more information about how to work with TableQuery

Upvotes: 1

Related Questions