aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/select/hits_count.sql
blob: df10886307d965841c4439752c2589f4917e61bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* postgres can not */
USE plato;

$data = (
    SELECT
        Url::Normalize(value) AS normalized_url,
        Url::GetHost(Url::Normalize(value)) AS host,
        Url::GetDomain(Url::Normalize(value), 1) AS tld
    FROM CONCAT(
        `Input1`,
        `Input2`
    )
);
$ru_hosts = (
    SELECT
        host
    FROM
        $data
    WHERE normalized_url IS NOT NULL AND (
           tld = "ru"
        OR tld = "su"
        OR tld = "рф"
        OR tld = "xn--p1ai" -- punycode рф
    )
);

SELECT
    host AS host,
    COUNT(*) AS hits_count
FROM $ru_hosts
GROUP BY host
ORDER BY hits_count DESC
LIMIT 25;