Get the last data of my google analytics dataset

118 views Asked by At

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?

3

There are 3 answers

0
israel altar On

Try to use ' instead of ":

 CONTAINS 'ga_sessions'

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

0
Jordan Tigani On

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)")
0
Mariana Alves On

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