select
(select count(*) as total from t_name where t_name.posttext @@ websearch_to_tsquery('simple_german','Robert Prosinecki')),
( select('Robert Prosinecki') as input),
t_name.name,
max(t_name.posttext::TEXT) as posttext,
count(distinct(t_ref.textid)),
max(t_ref.urlid) as urlid,
max(t_ref_time.datetime) as datetime,
max(t_ref.textid) as textid,
(select t_url_meta.description from t_url_meta where t_url_meta.id = max(t_ref.urlmetaid)),
(select t_url_meta.title from t_url_meta where t_url_meta.id = max(t_ref.urlmetaid)),
(select t_url.id from t_url where t_url.id = max(t_ref.urlid)),
(select substring(t_text.inhalt, position(lower('Robert Prosinecki') in lower(t_text.inhalt)), 250) as inhalt from t_text where t_text.id = max(t_ref.textid) limit 1),
(select t_url.url from t_url where t_url.id = max(t_ref.urlid) limit 1),
(select t_subdomain.subdomain from t_subdomain where t_subdomain.id = max(t_ref.subdomainid) limit 1),
(select t_domain.domain from t_domain where t_domain.id = max(t_ref.domainid) limit 1),
max(t_ref.domainid) as domainid,
max(t_ref.subdomainid) as subdomainid,
max(t_ref.tldid) as tldid,
max(t_ref.id) as refid,
(select t_tld.tld from t_tld where t_tld.id = max(t_ref.tldid) limit 1)
from t_name
join t_name_id on t_name_id.name_id = t_name.id
join t_ref on t_ref.id = t_name_id.refid
join t_ref_time on t_ref_time.refid = t_ref.id
join t_text on t_text.id = t_ref.textid
join t_url_meta on t_url_meta.id = t_ref.urlmetaid
join t_domain on t_domain.id = t_ref.domainid
join t_subdomain on t_subdomain.id = t_ref.subdomainid
where t_name.posttext @@ websearch_to_tsquery('simple_german','Robert Prosinecki') group by t_name.name
order by t_name.name asc limit 10;