Suppose you have a table that records visitor information of the visitors of your website. The information of a visitor includes it's IP address, request URI, referee, user agent, etc. The data is stored in a MySQL database table. Here is the table definition:
Here is SQL code example to get total number of all visitors comes from Google SERPs in a particular month.Here is SQL code example to get total number of all visitors comes from Google SERPs in .
When there is subquery, it can be exetremly slow even hangs forever in MySQL. Here is an example.
This query first collects the ip addresses have 1000 or more visiting records come from them, and then query the total number of visiting records come from all those IP addresses.