Answer the question
In order to leave comments, you need to log in
How to make such sql query?
Travel agency theme. People fly to different countries.
Question : how to withdraw those who have been to " 2 countries at least twice "?
There is a table "order" in which fields, for example, date, country, client. How to make such requests? Thanks in advance!
Answer the question
In order to leave comments, you need to log in
For MySQL it would be something like this:
SELECT `client_id`
FROM (
SELECT `client_id`, `country_id`
FROM `orders`
GROUP BY `client_id`, `country_id`
HAVING COUNT(*) > 1
) AS `t1`
GROUP BY `client_id`
HAVING COUNT(*) > 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question