How to get count of a field in another table codeigniter using group by?
<p>I have a table called sitekeys:</p>

<p><a href="https://i.stack.imgur.com/6WQ3L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6WQ3L.png" alt="sitekeys"></a></p>

<p>In this site_key contains a unique license. And The field called licenses contains the no of times it can be used. the org_id field contains the company to which it has been assigned.</p>

<p>Now the activation table:</p>

<p><a href="https://i.stack.imgur.com/iUhFS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iUhFS.png" alt="activation"></a> </p>

<p>in this table site_key contains the keys assigned to the device.</p>

<p>Now I want to count The keys used for a company.</p>

<p>Like for XYZ company i has give 10 licenes then i want to know how many of them are used by it, so for that i can count(site_key) in activation table.</p>

<p>So what should be my query here?</p>

<p>I think i wil have to use Group_BY to do so.</p>

<p><strong>I want show the keys i gave to a company and the keys they have used</strong></p>