Simple: I would like to count the number of rows from the sub-query. Note that status itis whether the host is online or not.
Bad code: ###Bad code
SELECT COUNT(ip_address) FROM `ports` (
SELECT DISTINCT ip_address FROM `ports` WHERE status IS TRUE
)
Explained: ###Explained
1stThe first query, when run on its own returns this:
SELECT DISTINCT ip_address FROM `ports` WHERE status IS TRUE
ip_address
192.168.1.1
192.168.1.2
192.168.1.248
192.168.1.251
192.168.1.254
ip_address
192.168.1.1
192.168.1.2
192.168.1.248
192.168.1.251
192.168.1.254
2ndThe second query run on its own returns this:
SELECT COUNT(ip_address) FROM `ports`
17
17
Question: Just would like to know how to count that list of 5 IP addreses. ###Question
I would like to know how to count that list of 5 IP addresses.
I have been looking online at possible solutions to this simple problem and just getting frustrated, so thought I'd ask the experts.