使用Socrata SODA API按日期时间查询最新行 [英] Using Socrata SODA API to query most recent rows by datetime

查看:54
本文介绍了使用Socrata SODA API按日期时间查询最新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个网站的新手,这是我的第一个问题.我正在尝试从Socrata Seattle Open Data网站查询"Seattle Real Fire 911 Calls"数据库:

I am new to this site and this is my first question. I am trying to query the "Seattle Real Time Fire 911 Calls" database from the Socrata Seattle Open Data site: https://data.seattle.gov/Public-Safety/Seattle-Real-Time-Fire-911-Calls/kzjm-xkqj. I'm not an expert at using the SODA API, and I'm having difficulty figuring out how to query the most recent entries in the database. All attempts to use the "order" or "where" SoQL statements give me data from 2010 or 2011, and I cannot figure out how to query the most recent 300 entries. Querying the "top" rows yields the oldest entries. Using a full OData feed pull yields data as recent as today, but I need to use a fast json or csv SODA API query.

注意:datetime字段不响应我使用的任何"where"语句.

Note: The datetime field does not respond to any "where" statements that I use.

谢谢!

推荐答案

好的,一些入门技巧:

  • $ order 参数默认情况下以升序( ASC )排序,因此您实际上需要按 datetime DESC 进行排序,以便首先获取最新记录
  • 不幸的是,西雅图列出了许多没有 datetime 的犯罪,因此您还希望使用 $ where 查询进行过滤,以便仅检索日期范围. $ where = datetime>例如,"2014-07-01" 对我有用
  • 要仅获取前300个结果,您还需要传递一个 $ limit = 300 参数.
  • The $order parameter sorts by default in ascending (ASC) order, so you'll want to actually order by datetime DESC to get the latest records first
  • Unfortunately Seattle has a number of crimes that are listed with no datetime, so you'll also want to filter with a $where query to only retrieve results in a date range. $where=datetime > '2014-07-01' works for me, for example
  • To only get the top 300 results, you'll want to pass a $limit=300 parameter as well.

这是一个示例请求在Runscope中供您试用.

Here's a sample request in Runscope for you to try out.

这篇关于使用Socrata SODA API按日期时间查询最新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆