sql - Multiple sort/filter factors on a Fusion tables query -
i want perform query on google fusion table. let's assume assembling string below variables. works fine if have 1 parameter in var sort_factors
. how can add second parameter sort_factors
can both (for example) order date descending , limit response 1000 rows?
var base = 'https://www.googleapis.com/fusiontables/v2/query?', columns = 'sql=select+lat,lng,date,username,tripid', = '+from+xxxxxxxxxxxxxxxxxxx', sort_factors = '+limit+1000+and+order+by+date+desc', key = '&key=xxxxxxxxxxxxxxxxxxx';
limit
isn't sorting, and
wrong there , limit has last clause in sql:
'+order+by+date+desc+limit+1000'
the order of clauses fixed , has be:
- where
- group
- order
- limit
your code seems javascript, better favour , let js handle encoding.
possible approach:
var base = 'https://www.googleapis.com/fusiontables/v2/query', columns = 'select lat,lng,date,username,tripid', = 'from fusiontableid', //apply filter when want = '', //group results when want groupby = '', orderby = 'order date desc', limit = 'limit 1000', key = 'yourapikey', //do want jsonp-response? add callback-parameter callback = '&callback=functionname', //prepare query; sql = encodeuricomponent([columns, from, where, groupby, orderby, limit].join(' ')), //prepare url url = [base, '?sql=', sql, callback, '&key=', key].join(''); //see got document.body.appendchild(document.createtextnode(url));
body { font-family: monospace }
demo using 4 clauses: http://jsfiddle.net/doktormolle/fc47243g/
Comments
Post a Comment