假设我想获得每个国家 (Q6256) 及其最近记录的人类发展指数 (P1081) 值的列表。该国家/地区的人类发展指数属性包含在不同时间点采集的数据点列表,但我只关心最新数据。此查询将不起作用,因为它会为每个国家/地区获得多个结果(每个人类发展指数数据点一个):
SELECT
?country
?countryLabel
?hdi_value
?hdi_date
WHERE {
?country wdt:P31 wd:Q6256.
OPTIONAL { ?country p:P1081 ?hdi_statement.
?hdi_statement ps:P1081 ?hdi_value.
?hdi_statement pq:P585 ?hdi_date.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Run Code Online (Sandbox Code Playgroud)
我知道 GROUP BY/GROUP CONCAT 但是当我更喜欢只有一个结果时,它仍然会给我每一个结果。GROUP BY/SAMPLE 也将不起作用,因为 SAMPLE 不能保证采用最新的结果。
感谢任何帮助或相关示例查询的链接!
PS我感到困惑的另一件事是为什么这个查询中的人口P1082每个国家只返回一个人口结果
SELECT
?country
?countryLabel
?population
WHERE {
?country wdt:P31 wd:Q6256.
OPTIONAL { ?country wdt:P1082 ?population. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Run Code Online (Sandbox Code Playgroud)
而相同的查询但对于 HDI 会返回每个国家/地区的多个结果:
SELECT
?country
?countryLabel
?hdi
WHERE {
?country …Run Code Online (Sandbox Code Playgroud) 我一直在试图找出过去几天发生这种情况的原因并没有成功.我在Laravel中路由时发现了一些其他问题来处理403错误,但没有一个问题涉及单个路由的问题.Laravel和Web开发有点新,所以可能会遗漏一些明显的东西,但是这里有:
所以我的项目中的路由都工作,除了一个,该路由是{mywebsite}/admin,这给了我403错误.当我去{mywebsite} /index.php/admin时,它确实有效.我不明白为什么我的其他路线都没有同样的问题.例如,{mywebsite}/test有效,{mywebsite}/admin/categories有效.这实际上是唯一不起作用的路线.另外值得注意的是,尝试在我的本地服务器和生产服务器(带有Laravel Forge的Digital Ocean)上访问它时会出现同样的问题.
这是我的routes.php文件:
Route::get('/', function()
{
return View::make('hello'); //works
});
Route::get('/admin', function()
{
return "admin"; //403 error
});
Route::get('/test', function()
{
return "test"; //works
});
//these all work
Route::get('/admin/dashboard', 'TaskCategoriesController@showAdmin');
// all category routes
Route::get('/admin/categories/', 'TaskCategoriesController@show');
Route::get('/admin/categories/{id}/edit', 'TaskCategoriesController@edit');
Route::post('/admin/categories/{id}/edit/', array('uses' => 'TaskCategoriesController@update'));
Route::post('/admin/categories/create/{id}', array('uses' => 'TaskCategoriesController@create'));
Route::get('/admin/categories/delete/{id}', array('uses' => 'TaskCategoriesController@delete'));
Route::get('/admin/categories/create', function()
{
return View::make('CreateCategory');
});
// all form routes
Route::get('/admin/forms/{id}/edit', 'TaskFormsController@edit');
Route::post('/admin/forms/{id}', 'TaskFormsController@create');
Route::post('/admin/forms/{id}/submit', 'OrdersController@submitOrder');
Route::get('/admin/forms/{id}/add', 'TaskFormsController@addFormElement');
Route::get('/admin/forms/{id}/edit/{elementId}', 'TaskFormsController@editFormElement');
Route::get('/admin/forms/{id}/delete/{elementId}', 'TaskFormsController@deleteFormElement');
Route::post('/admin/forms/{id}/saveUpdates/{tid}', 'TaskFormsController@updateFormElement');
//time …Run Code Online (Sandbox Code Playgroud)