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 7 months ago #13669

  • IRedsell
  • IRedsell's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0
Has anyone yet got an example of how to get a new user attendance report from the newer implementation (7.5.5) which has user and event fields normalised?

I used to be able to report on DTUser table but now the fields are looked up I am running short of SQL expertise to do the lookups into the field tables to get the fields out I need.

I am using Jevents linked and I would like to get a selection of users, fields, members for a selected event. I could use CSV export but I am actually creating a SQL2Excel report for the front end where the users can pick an event and see who is going too!

My brain has expired in the new world of sub selects.....
Any help much appreciated - Thank you.

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

Report SQL for events Users and Group members 13 years 7 months ago #13677

  • marcporter
  • marcporter's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0
I received some great help, so I thought I would share what I learned
This is from user suyog

SELECT X.groupMemberId, B.title,
MAX(CASE WHEN A.field_id = 48 THEN value END) AS FIRSTNAME,
MAX(CASE WHEN A.field_id = 49 THEN value END) AS LASTNAME,
MAX(CASE WHEN C.field_id = 58 THEN value END) AS ORGANIZATION,
MAX(CASE WHEN C.field_id = 50 THEN value END) AS ADDRESS,
MAX(CASE WHEN C.field_id = 51 THEN value END) AS ADDRESS2,
MAX(CASE WHEN C.field_id = 52 THEN value END) AS CITY,
MAX(CASE WHEN C.field_id = 53 THEN value END) AS STATE,
MAX(CASE WHEN C.field_id = 54 THEN value END) AS ZIP
FROM ` jos_dtregister_group_member` AS X
INNER JOIN ( SELECT * FROM jos_dtregister_member_field_values) AS A ON X.groupMemberID = A.member_id
INNER JOIN ( SELECT * FROM jos_dtregister_group_event) AS B ON X.eventId = B.slabId
INNER JOIN ( SELECT * FROM jos_dtregister_group_amount) AS C ON X.userID = C.groupId
GROUP By X.userID

This should give you an idea of how to do it for group members... The field_id can be found in the table jos_dtregister_fields

Here is how I modified it for individual registrations
SELECT C.title as Title, B.fee, B.paid_amount,
CASE B.status
WHEN 1 THEN 'Yes'
ELSE 'No'
END AS Paid,
CASE B.payment_method
WHEN 1 THEN 'Pay Later'
WHEN 2 THEN 'Pay Later'
WHEN 3 THEN 'Pay Later'
END AS Method,
MAX(CASE WHEN A.field_id = 16 THEN value END) AS FIRSTNAME,
MAX(CASE WHEN A.field_id = 17 THEN value END) AS LASTNAME,
MAX(CASE WHEN A.field_id = 18 THEN value END) AS ADDRESS,
MAX(CASE WHEN A.field_id = 19 THEN value END) AS ADDRESS2,
MAX(CASE WHEN A.field_id = 20 THEN value END) AS CITY,
MAX(CASE WHEN A.field_id = 21 THEN value END) AS STATE,
MAX(CASE WHEN A.field_id = 22 THEN value END) AS ZIP,
MAX(CASE WHEN A.field_id = 9 THEN value END) AS Unit
FROM `jos_dtregister_user` AS X
INNER JOIN ( SELECT * FROM jos_dtregister_user_field_values)AS A ON X.userId = A.user_id
INNER JOIN ( SELECT * FROM jos_dtregister_fee) AS B ON X.userID=B.user_id
INNER JOIN ( SELECT * FROM jos_dtregister_group_event) AS C on X.eventId=C.slabId
WHERE C.category=3
GROUP By X.userId

I added an CASE operation to the payment method and payment status, so it didn't just display a number. I added the WHERE statement on the second to last line to only querry on events in a specific category, you could change that to an event id, or leave it off for all records. This isn't complete, but should give you a starting point, it certainly helped me out.

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

Report SQL for events Users and Group members 13 years 7 months ago #13716

  • IRedsell
  • IRedsell's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0
Marc

thanks for the examples, the individual one works fine, the group one the joins appear to be incorrect so I can work on the individual example for now

Thanks again

Ian

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

Report SQL for events Users and Group members 13 years 7 months ago #13718

  • sfsailing
  • sfsailing's Avatar
  • Visitor
  • Visitor
This topic is of great interest to me.
The user registration data seems to be very hard to get to, I am very confused as to where to look for it.
What tool are you using to do your reporting?
Thanks

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

Report SQL for events Users and Group members 13 years 6 months ago #13728

  • steve30000
  • steve30000's Avatar
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 106
  • Thank you received: 0

sfsailing wrote: This topic is of great interest to me.
The user registration data seems to be very hard to get to, I am very confused as to where to look for it.
What tool are you using to do your reporting?
Thanks


SQL 2 Excel joomla extension: http://extensions.joomla.org/extensions ... ports/7413

There is also a pro version with additional features.

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

Report SQL for events Users and Group members 13 years 4 months ago #14480

  • cmulgrum
  • cmulgrum's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0
Can someone help me to write a SQL query that would match the CSV Export but also add fields to the export? I want to add it to SQL2Excel to attempt to create normalized tables.

My SQL expertise is just about novice and I have no understanding of the tables in DTRegister.

Many Thanks
Craig

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

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