I have a question about STAT relational query if anyone can help or tell me if it is possible?
I have three related tables
User - represents a user
Schedule - represents an instance of an item being scheduled. An item could have multiple schedules if it when through the process multiple times.
Control - Represents the single item all in the system always.
Schedule relates to User with user_id and control with control_id
I’m trying to count the number of sold items for the user through a STAT relation where Schedule has the user_id and relates to a control with control_id and Schedule.Item_status_id = Control.Item_status_id and control.Item_status_id = (a claimed status id )
the raw MySQL query to get this answer would look something like this:
SELECT COUNT(*) FROM Schedule AS S JOIN Control AS C ON(S.control_id = C.id and S.Item_Status = C.item_status_id) WHERE S.User_id = {our user model id} and C.item_Status_id=5