Write a query to display the customer name who visited the second highest number of times
select customer_id,count(*) from booking group by customer_id ;
SELECT customer_id, COUNT(*) FROM booking GROUP BY customer_id HAVING COUNT(*) <> (SELECT MAX(t.custCount) FROM (SELECT COUNT(*) AS custCount FROM booking GROUP BY customer_id) t ) ORDER BY COUNT(*) DESC LIMIT 1
As a side note, this won't work if there are ties for second place. In this case, you use the above query as a condition in the
WHERE clause, e.g.
SELECT customer_id FROM booking GROUP BY customer_id HAVING COUNT(*) = (query given above)