Sorry I'm a bit rusty on doing Moodle DB queries. Let's say that I have some custom user profile fields (e.g. for user's demographic data), and I want to write a query that it would display user's user profile data based on the GROUPS that they are in (e.g. GROUP1, GROUP2...etc.). How would you approach to write query?
Here is what I found:
Courses that are defined as using GROUPs
SELECT concat('<a target="_new" href="%%WWWROOT%%/group/index.php?id=',c.id,'">',c.fullname,'</a>') AS Course
,(SELECT COUNT(*) FROM prefix_course_modules cm WHERE cm.course = c.id) Modules
,(SELECT COUNT(*) FROM prefix_groups g WHERE g.courseid = c.id) Groups
FROM `prefix_course` AS c
WHERE groupmode > 0