-- Top applications by number of bytes

SELECT
    SPLIT_PART("nDPIclass", '.', 1) AS appl,
    SUM("numBytesSnt") + SUM("numBytesRcvd") AS cnt
FROM
    flow
WHERE
    ("flowStat"::BIGINT & 1) = 0::BIGINT
    AND "timeFirst" >= to_timestamp(:time_from)
    AND "timeLast" <= to_timestamp(:time_to)

GROUP BY appl
ORDER BY cnt DESC

LIMIT :n
