title: MySQL INNER JOIN query to get client information having at least 10 rentals
body: <p>I am trying to query the code, name, and the number of rentals of customers who have made at least ten rentals.</p>
  <p>My query:</p>
  <pre><code>Select client.ClientCode, client.ClientNom, (location.LocationRef)
  FROM client
    INNER JOIN location ON client.ClientCode = location.ClientCode
  WHERE location.LocationRef &gt; 9
  GROUP BY location.ClientCode;
  </code></pre>
  <p>Output:</p>
  <pre><code>ClientCode | ClientNom | LocationRef
  -----------+-----------+------------
  12874      | Alex      | 10
  </code></pre>
  <p>It doesn't work. It shows me the first <code>LocationRef</code> beyond 10 but not the number of rentals made by the client.</p>
  <p>I test with a <code>COUNT</code> in my query :</p>
  <pre><code>SELECT client.ClientCode, client.ClientNom, Count(location.LocationRef) 
    FROM client 
      INNER JOIN location 
        ON client.ClientCode = location.ClientCode WHERE location.LocationRef &gt; 9 
  GROUP BY location.ClientCode;
  </code></pre>
  <p>This is what i got :</p>
  <pre><code>ClientCode | ClientNom | Count(location.locationRef)
  -----------+-----------+----------------------------
  12874      | Alex      | 5
  </code></pre>
  <p>This is not what I want, because my client has made 13 rentals and it only shows me the number of rentals beyond the 9th rental.</p>
  <p>Script to install my database:</p>
  <pre><code>SET SQL_MODE = &quot;NO_AUTO_VALUE_ON_ZERO&quot;;
  START TRANSACTION;
  
  SET time_zone = &quot;+00:00&quot;;
  
  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  /*!40101 SET NAMES utf8mb4 */;
  
  CREATE TABLE `client` (
    `ClientCode` int(11) NOT NULL,
    `ClientNom` varchar(255) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  INSERT INTO `client` (`ClientCode`, `ClientNom`) VALUES
  (123, 'Gaetan'),
  (12874, 'Alex'),
  (12875, 'Max');
  
  CREATE TABLE `location` (
    `LocationRef` int(11) NOT NULL,
    `Immatriculation` varchar(11) NOT NULL,
    `ClientCode` int(11) NOT NULL,
    `MontantLocation` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  INSERT INTO `location` (`LocationRef`, `Immatriculation`, `ClientCode`, `MontantLocation`) VALUES
  (1, 'AA-229-AA', 12874, 123), (2, 'AA-229-AB', 12875, 156),
  (3, 'BA-229-AA', 12874, 700), (4, 'AB-229-AA', 12874, 678),
  (5, 'AA-229-AB', 12874, 987), (6, 'AA-229-AB', 12874, 980),
  (7, 'AB-229-AA', 12874, 567), (8, 'AA-229-AA', 12874, 7789),
  (9, 'AA-229-AB', 12874, 567), (10, 'AA-229-AB', 12874, 456),
  (11, 'AA-229-AA', 12874, 566), (12, 'AB-229-AA', 12874, 700),
  (13, 'AA-229-AA', 12874, 899), (14, 'AA-229-AB', 12874, 67);
  </code></pre>