I have a database the tells each systems current and new model. (Each row has a system name, current model, and new model) I need to group the results by the current model and new model. So if the current and new model are the same i want one result. I got that to work but i also need to know how many systems are in each group. How can I do that? Im using CI
This is my query
$query2 = $this->db->query('SELECT * FROM rollout_systems WHERE scope_ID = '.$id.' GROUP BY EAM_Model, new_Model');
(EAM_Model = current model)
Don’t know if i clarified enough. I need to be able to display the Current System, the New System, and the number of systems in that group.
So if 3 rows have “blah” as there current system and “blahblah” as there new system, i want it to say
Current: Blah
New: Blah Blah
number of systems: 3
It doesn’t make sense to do a select * and a group by in the same statement. The columns you group by need to be in your select but then you should have an aggregate function like count(*) in your select. I’m not sure I totally understand what you are trying to do, but I think you want something like: