DB query for STAT table

Hello, I would like to understand how to extract statistical data from XIBO to perform very customized measurements for the client. I am trying this query, but I don’t understand why it gives different results compared to the application’s reports. Where am I going wrong or how can I better understand the Xibo database?

USE cms;

SELECT
s.statId,
s.type,
s.statDate,
s.scheduleId,
s.displayId,
d.display AS displayName,
s.campaignId,
s.layoutId,
l.layout ,
s.widgetId,
s.start,
s.end,
s.duration,
s.count,
s.parentCampaignId
FROM
stat s
JOIN
display d ON s.displayId = d.displayId
JOIN
lkdisplaydg lkd ON d.displayId = lkd.displayId
JOIN
displaygroup dg ON lkd.displayGroupId = dg.displayGroupId
JOIN
layout l ON s.layoutId = l.layoutId
WHERE
d.display LIKE ‘MAC_ORIZ_3840 x 2160_PDV368_retrobancoDx’
AND
s.statDate >= UNIX_TIMESTAMP(CURDATE() - INTERVAL 1 DAY)
AND
s.statDate < UNIX_TIMESTAMP(CURDATE());

Hi @Arturo_Blacona

Maybe it’s a question of time with UNIX_TIMESTAMP(CURDATE() - INTERVAL 1 DAY) and UNIX_TIMESTAMP(CURDATE())

What data is returned from these functions and which ones are in the database?

Sorry for the late reply.

The join to layout is probably the issue here, if you have draft/published the layout during or since its stat collection, the layout it will have changed.

You should always go through the layouthistory table when linking to stats.

Thanks, Dan, for your response. I’ll try your suggestions as soon as possible.