Hello
I’m having two tables ap_user and read_page. I want write query that returns how user is logged from ip address and how pages read from ip addres. In table read_page one record is one page readied.
ap_user-------------------------
| user_id | ip | device_model |
| 1 | 195.14.172.97 | Nokia3510i |
| 2 | 195.14.172.97 | Nokia7650 |
| 3 | 194.176.32.169 | SIE-SX1 |
| 4 | 195.14.172.97 | Nokia7650 |

read_page------------------
| date | user_id | page_id |
| 2005-01-07 | 1 | 1 |
| 2005-01-07 | 1 | 8 |
| 2005-01-07 | 2 | 3 |
| 2005-01-07 | 1 | 4 |
| 2005-01-08 | 3 | 9 |
| 2005-01-08 | 1 | 5 |
When using the second query get how users are logged from ip. SELECT ap_user.ip, COUNT(ap_user.user_id), FROM ap_user GROUP BY ap_user.ip
But when execute second query returns only good data how pages readied from ip and bad data how users are logged from ip.
SELECT ap_user.ip, COUNT(ap_user.user_id), COUNT(read_page.page_id) FROM ap_user LEFT JOIN read_page USING(user_id) GROUP BY ap_user.ip

Maybe can write good query, that can get how user is logged from ip address and how pages read from ip address? Please!