W3C home > Mailing lists > Public > semantic-web@w3.org > November 2012

Re: Counting datatypes per property

From: Heiko Paulheim <paulheim@ke.tu-darmstadt.de>
Date: Thu, 08 Nov 2012 14:08:39 +0100
Message-ID: <509BAED7.5010802@ke.tu-darmstadt.de>
To: Richard Cyganiak <richard@cyganiak.de>
CC: semantic-web@w3.org, Dominik Wienand <dominik.wienand@online.de>
Perfect! Thanks, Richard, for both the solution and the explanation :-)

Best,
Heiko


Am 08.11.2012 14:05, schrieb Richard Cyganiak:
> Heiko,
>
> This should work:
>
>    SELECT (DATATYPE(?y) AS ?datatype) (COUNT(*) AS ?count) {
>        ?x dbpprop:utcOffset ?y
>    } GROUP BY DATATYPE(?y)
>
> On 8 Nov 2012, at 10:43, Heiko Paulheim wrote:
>> we are trying to analyze datatype properties by the datatype they use. Our first idea was to use a simple SPARQL query per property, however, the following does not do what I would expect it to do:
>>
>> SELECT COUNT(?x) DATATYPE(?y) WHERE {?x dbpprop:utcOffset ?y}
>>
>> This query does not group all entries with, e.g., <http://www.w3.org/2001/XMLSchema#int> in one row. Why not?
> To understand what your query is actually doing, run this:
>
>    SELECT ?y COUNT(?x) DATATYPE(?y) WHERE {?x dbpprop:utcOffset ?y}
>
> The best way I can explain this: The "COUNT(?x)" introduces an implicit "GROUP BY ?y", because ?y is the only variable not used in an aggregate function, and so each result you get is for one distinct value of ?y, and not for one distinct datatype of ?y as you want.
>
> Here's a fixed one. The main point is the GROUP BY clause that explicitly groups by distinct datatypes.
>
>    SELECT (DATATYPE(?y) AS ?datatype) (COUNT(*) AS ?count) {
>        ?x dbpprop:utcOffset ?y
>    } GROUP BY DATATYPE(?y)
>
> Best,
> Richard
>
>
>> What am I doing wrong here?
>>
>> Best regards,
>> Heiko
>>
>>
>> -- 
>> Dr. Heiko Paulheim
>> Knowledge Engineering Group
>> Technische Universitšt Darmstadt
>> Phone: +49 6151 16 6634
>> Fax:   +49 6151 16 5482
>> http://www.ke.tu-darmstadt.de/staff/heiko-paulheim
>>
>>

-- 
Dr. Heiko Paulheim
Knowledge Engineering Group
Technische Universitšt Darmstadt
Phone: +49 6151 16 6634
Fax:   +49 6151 16 5482
http://www.ke.tu-darmstadt.de/staff/heiko-paulheim
Received on Thursday, 8 November 2012 13:09:07 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 21:45:52 GMT