c++ - Sqlite - Count Unique Values based on Column -
c++ - Sqlite - Count Unique Values based on Column -
i've got table (c, sqlite). , want count number of unique ports each ip address contacts.
id | ip_src | ip_dst | port ----------------------------------- 1 | 192.168.45.3 | ... | 442 2 | 132.43.13.4 | ... | 42 3 | 111.5.34.3 | ... | 80 4 | 54.2.2.1 | ... | 8322 5 | 54.2.2.1 | ... | 8322 6 | 192.168.45.3 | ... | 80 7 | 192.168.45.3 | ... | 23
the result of query should ideally this:
192.168.45.3 = 3 132.43.13.4 = 1 111.5.34.3 = 1 54.2.2.1 = 1
what query this?
i've tried:
select src_ip, count(distinct port) synpackets;
but it's not giving out right result, seems counting first ip address.
it's of import unique ports first. therefore, have nest 2 select statements this:
select t.ip_src ip_src, count(t.ports) numberports (select distinct ip_src, ports <table>) t grouping t.ip_src;
in inner select statement results unique ip_src , ports pairs. using recordset can count ports. mind group by
. otherwise not unique port count.
c++ mysql sqlite
Comments
Post a Comment