Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Report SQL for events Users and Group members

Report SQL for events Users and Group members 13 years 3 months ago #14663

  • waynejb
  • waynejb's Avatar
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 131
  • Thank you received: 4
I would also be very interested in the basic sql as I am not an expert by any means.
I could not get either of the samples above to provide data within a report.

Please Log in or Create an account to join the conversation.

Report SQL for events Users and Group members 13 years 3 months ago #14827

  • divalsafety
  • divalsafety's Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 45
  • Thank you received: 0
Try this, I revised a number of different queries and credit goes out to everyone who helped me on this forum. Obviously match the field ID and event ID values to reflect your database. Have fun!
(SELECT u.userId AS UserID, u.type AS RegType,
GROUP_CONCAT(IF(m.field_id = 12, m.value, NULL)) AS Organization,
GROUP_CONCAT(IF(m.field_id = 2, m.value, NULL)) AS FirstName,
GROUP_CONCAT(IF(m.field_id = 3, m.value, NULL)) AS LastName,
GROUP_CONCAT(IF(m.field_id = 10, m.value, NULL)) AS Email,
GROUP_CONCAT(IF(m.field_id = 11, m.value, NULL)) AS Phone,
GROUP_CONCAT(IF(m.field_id = 23, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(m.value AS UNSIGNED)+1),'|',-1),NULL)) AS Poll,
GROUP_CONCAT(IF(m.field_id = 21, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(m.value AS UNSIGNED)+1),'|',-1),NULL)) AS "Sales Rep",
u.register_date AS RegDate,
u.confirmNum AS Confirm#
FROM jos_dtregister_user u 
LEFT JOIN jos_dtregister_group_member g ON g.groupUserId = u.userId 
INNER JOIN jos_dtregister_member_field_values m ON m.member_id = g.groupMemberId
INNER JOIN jos_dtregister_group_event e ON e.slabId = u.eventID
INNER JOIN jos_dtregister_fields f ON m.field_id = f.id
WHERE u.eventID = 25
GROUP BY m.member_id)
UNION
(SELECT u.userId AS UserID, u.type AS RegType,  
GROUP_CONCAT(IF(v.field_id = 12, v.value, NULL)) AS Organization,
GROUP_CONCAT(IF(v.field_id = 2, v.value, NULL)) AS FirstName,
GROUP_CONCAT(IF(v.field_id = 3, v.value, NULL)) AS LastName,
GROUP_CONCAT(IF(v.field_id = 10, v.value, NULL)) AS Email,
GROUP_CONCAT(IF(v.field_id = 11, v.value, NULL)) AS Phone,
GROUP_CONCAT(IF(v.field_id = 23, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(v.value AS UNSIGNED)+1),'|',-1),NULL)) AS Class,
GROUP_CONCAT(IF(v.field_id = 21, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(v.value AS UNSIGNED)+1),'|',-1),NULL)) AS "Sales Rep",
u.register_date AS RegDate,
u.confirmNum AS Confirm#
FROM jos_dtregister_user u 
INNER JOIN jos_dtregister_user_field_values v ON v.user_id = u.userId
INNER JOIN jos_dtregister_group_event e ON e.slabId = u.eventID
INNER JOIN jos_dtregister_fields f ON v.field_id = f.id
WHERE u.eventID = 25
GROUP BY u.userID)
ORDER BY RegDate DESC, Organization DESC, FirstName

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Time to create page: 0.569 seconds