How can i use group by for following case:
I have a table called Sitekey in here i have list of License keys.
The Site_Key field contains the license keys for my product. The Org_id contains the id of the organization to which that key has been assigned.
Now I have another table called activation. Its Structure is:
Now in this table Site_key contains the license(key). and the device information.
Now I want to show licenses available in table to whom they are assigned.
I do this :
public function get_key()
{
$this->db->select('*');
$this->db->from('sitekey');
$this->db->join('company', 'sitekey.org_id = company.id');
$this->db->order_by('sitekey.id','desc');
$query = $this->db->get();
$result = $query->result();
return $result;
}
Now I want get the count of keys that are used in activation table! > in sitekey table the licenses field contains the number of licenses so the company can use that key for that number of times. Now i want to get the key i gave them and the keys they have used from it. So i guess i need to use group by So how can i write such a query ?
Note
I want to count the keys in activation table. For eg there is a key :4CAC-9CA7 Then i want to know how many times it has been used ? So i want to count all this for all keys
The Company Table:



$this->db->group_by("columnName");??