Morrison Cole
Morrison Cole

Reputation: 3127

Fusion Tables query for grouped data timing out

Using the guidelines here I have successfully queried a simple fusion table for some basic data with the following code:

google.load('visualization', '1', { packages: ['corechart'] });

  function drawVisualization() {
        google.visualization.drawChart({
            containerId: 'visualization',
            dataSourceUrl: 'http://www.google.com/fusiontables/gvizdata?tq=',
            query: 'SELECT sector, revenue FROM 2961086',
            chartType: 'LineChart',
            options: {
                title: 'Net Revenue by Sector',
                vAxis: {
                    title: 'Revenue'
                },
                hAxis: {
                    title: 'Sector'
                }
            }
        });
  }

  google.setOnLoadCallback(drawVisualization);

A problem arises when I attempt to aggregate the data by sector. I've tried the following

query: 'SELECT sector, revenue FROM 2961086 GROUP BY sector'

with no luck, the request eventually times out.

I threw together two pages demonstrating the issue.

I've also tried queries with various other parameters that work with no trouble whatsoever. Am I missing something?

Upvotes: 2

Views: 340

Answers (1)

Eric Bridger
Eric Bridger

Reputation: 3794

I'm not a google.visualization user, just a fusion-table user but I would guess that you need an aggregate function in your query: SELECT sector, sum(revenue) from ... GROUP BY sector

Eric

Upvotes: 2

Related Questions