I'm using SQL in pgadmin4 (Postgres). I query a list of IP's and occurences of the IP's. If it matches the regex I want to print the regex and the sum of occurences.
I'm querying the following:
select distinct dstaddress, _col1 from test where _col1 > 1 AND
dstaddress LIKE '10.228.55.%' OR
dstaddress LIKE '10.228.9.%'
group by dstaddress, _col1
And this gives me as output the IP and its occurences:
"10.228.55.17" 365942
"10.228.9.104" 8
"10.228.9.105" 4
"10.228.9.106" 2
"10.228.9.107" 8
"10.228.9.108" 10
"10.228.9.109" 434
"10.228.9.110" 127
But as output I want to have the regex and the sum of occurences:
"10.228.55.%" 365942
"10.228.9.%" 593
How can I achieve this?