本文介绍了SPARQL希腊夏季的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想提出一个问题,对于希腊的每个地区来说,都应该计算出最好的沐浴水域(即显示完美质量的水域数量)。所以(排序的)结果应该是这样的: 克利特2048^^< http://www.w3 .ORG / 2001 / XMLSchema的#整数> #克里特岛有2048个完美的沐浴水域圣托里尼1024^^< http://www.w3.org/2001/XMLSchema#integer> .. 我的问题是如何获得与某个地区相关的沐浴水域。那么我应该担心如何收集不同的款项。我知道如何订购。假设?concie_0 确定质量;如果> 40,那么它的质量很好。这是我到目前为止: SELECT?municipality?bw WHERE {?regional_unit geo :έχει_επίσημο_όνομαΠΕΡΙΦΕΡΕΙΑΚΗΕΝΟΤΗΤΑΗΡΑΚΛΕΙΟΥ。 ?直辖市地区:ανήκει_σε?regional_unit。 ?城市地理位置:几何?几何。 ?bw geos:hasGeometry?bw_geo。 ?bw_geo geos:asWKT?bw_geo_wkt。 FILTER(strdf:within(?geometry,?bw_geo_wkt))。 ?bw unt:has_concie_0?concie_0。 FILTER(?concie_0> 40)} LIMIT 15 市政bw http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/340 http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/456 http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/972 http://geo.linkedopendata.gr/gag/id / 9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/1041 http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/ 1365 http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/1849 http://geo.linkedopendata.gr/gag / id / 9306 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/340 http: //geo.linkedopendata.gr/gag/id/9306 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/456 ... 我认为这个与每个区域单位一起沐浴水域。然而,我不知道该怎么做,你呢? 你需要做的就是改变你的 SELECT 子句包含 COUNT ,添加一个 GROUP BY 子句,自治市,最后是一个 ORDER BY 从句,确保得分最高。像这样: SELECT?municipality(COUNT(?bw)as?bwCount) WHERE { .... } GROUP BY?市政 ORDER BY DESC(?bwCount) I want to pose a query, which for every region of Greece, shall count the best bathing waters (i.e. the number of waters that show perfect quality). So the (ordered) result should be something like:Crete "2048"^^<http://www.w3.org/2001/XMLSchema#integer> # Crete has 2048 perfect bathing watersSantorini "1024"^^<http://www.w3.org/2001/XMLSchema#integer>..The problem for me is how to get the bathing waters related to a region. Then I should worry on how to collect different sums. I know how to order. Let's assume that ?concie_0 determines the quality; if > 40, then it is of perfect quality. Here is what I have so far:SELECT ?municipality ?bwWHERE { ?regional_unit geo:έχει_επίσημο_όνομα "ΠΕΡΙΦΕΡΕΙΑΚΗ ΕΝΟΤΗΤΑ ΗΡΑΚΛΕΙΟΥ" . ?municipality geo:ανήκει_σε ?regional_unit . ?municipality geo:έχει_γεωμετρία ?geometry . ?bw geos:hasGeometry ?bw_geo . ?bw_geo geos:asWKT ?bw_geo_wkt . FILTER(strdf:within(?geometry, ?bw_geo_wkt)) . ?bw unt:has_concie_0 ?concie_0 . FILTER(?concie_0 > 40)}LIMIT 15which gives:municipality bwhttp://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/340http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/456http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/972http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/1041http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/1365http://geo.linkedopendata.gr/gag/id/9302 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/1849http://geo.linkedopendata.gr/gag/id/9306 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/340http://geo.linkedopendata.gr/gag/id/9306 http://data.linkedeodata.eu/poiothta_ydatwn_kolymvhshs_2012/id/456...I think that this groups the bathing waters with every regional unit. However, I do not know how to proceed, do you? 解决方案 All you need to do is change your SELECT clause to include a COUNT, add a GROUP BY clause that groups per municipality, and finally an ORDER BY clause that ensures the highest scores come first. Like this:SELECT ?municipality (COUNT(?bw) as ?bwCount)WHERE { ....}GROUP BY ?municipalityORDER BY DESC(?bwCount) 这篇关于SPARQL希腊夏季的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-11 18:33