2016-08-13 83 views

回答

0

以下查询给了我我想要的。

select item.forecast.high, item.forecast.low from weather.forecast 
where woeid in (select woeid from geo.places(1) where text in ("ushuaia, ag", "dallas, tx")) 
and item.forecast.date="14 Aug 2016" 

我不知道为什么雅虎的主要YQL控制台(在这个问题链接)不与天气查询,这一刻的工作,但你仍然可以尝试在其weather API page查询。

结果:

{ 
"query": { 
    "count": 2, 
    "created": "2016-08-14T20:13:35Z", 
    "lang": "en-US", 
    "results": { 
    "channel": [ 
    { 
    "item": { 
     "forecast": { 
     "high": "25", 
     "low": "15" 
     } 
    } 
    }, 
    { 
    "item": { 
     "forecast": { 
     "high": "88", 
     "low": "75" 
     } 
    } 
    } 
    ] 
    } 
} 
} 
1

您可以加入一个子查询,该查询以匹配城市代码的降序返回最后两个日期。您需要加入城市代码和预测ID。

下面的SQL是T-SQL,但我想在YQL中会有类似的东西。

select item.forecast.high, 
    item.forecast.low 
from weather.forecast forecast 
JOIN (SELECT TOP 2 id, woeid, date 
    FROM weather.forecast 
    ORDER BY date DESC) dates ON dates.woeid = forecast.woeid 
          AND dates.id = forecast.id 
where woeid in (select woeid 
       from geo.places(1) 
       where text in ("ushuaia, ag", "dallas, tx")) 
+0

感谢您尝试帮助。作为全新的数据库,我不太明白你的答案。有一天我会回来的,但现在幸运的是,我找到了一个更简单的方法。 – bongbang

相关问题