SPARQL query and distinct count

If you’re using Java and Jena’s ARQ, you can use ARQ’s extensions for aggregates. Your query would look something like: SELECT ?tag (count(distinct ?tag) as ?count) WHERE { ?r ns9:taggedWithTag ?tagresource. ?tagresource ns9:name ?tag } LIMIT 5000 The original SPARQL specification from 2008 didn’t include aggregates, but the current version, 1.1, from 2013 does.

MySQL distinct count if conditions unique

Here’s one option using a subquery with DISTINCT: SELECT COUNT(*) gender_count, SUM(IF(gender=”male”,1,0)) male_count, SUM(IF(gender=”female”,1,0)) female_count FROM ( SELECT DISTINCT tel, gender FROM example_dataset ) t SQL Fiddle Demo This will also work if you don’t want to use a subquery: SELECT COUNT(DISTINCT tel) gender_count, COUNT(DISTINCT CASE WHEN gender=”male” THEN tel END) male_count, COUNT(DISTINCT CASE WHEN … Read more

Mysql count instances of substring, then order by

SELECT (CHAR_LENGTH(str) – CHAR_LENGTH(REPLACE(str, substr, ”))) / CHAR_LENGTH(substr) AS cnt … ORDER BY cnt DESC Yep, looks bloated but afaik there is no any other possible solution. mysql> select (CHAR_LENGTH(‘asd’) – CHAR_LENGTH(REPLACE(‘asd’, ‘s’, ”))) / CHAR_LENGTH(‘s’); +—————————————————————–+ | (CHAR_LENGTH(‘asd’) – CHAR_LENGTH(REPLACE(‘asd’, ‘s’, ”))) / CHAR_LENGTH(‘s’) | +—————————————————————–+ | 1.0000 | +—————————————————————–+ 1 row in set … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)