             petition_id
     ) AS max
 
-USING (
-    petition_id,
-    created_at
-);
+    USING (
+        petition_id,
+        created_at
+    )
+
+    INNER JOIN statuses s
+        ON s.id = ps.status_id
+;
+
+-- all signatures from the last 7 days
+SELECT
+    *
+
+FROM
+    signatures
+
+WHERE
+    created_at >= (DATE_SUB(NOW(), INTERVAL 7 DAY))
+;
+
+-- all signatures from the last day
+SELECT
+    *
+
+FROM
+    signatures
+
+WHERE
+    created_at >= (DATE_SUB(NOW(), INTERVAL 1 DAY))
+;
 
 -- GET Last 10 signatures and group them by petition_id
 SELECT

LIMIT 10
;



HAVING
    ps.created_at = MAX(ps.created_at)



SELECT
    n.*

FROM
    tblpm n
    INNER JOIN (
        SELECT
            control_number,
            MAX(date_updated) AS date_updated

        FROM
            tblpm

        GROUP BY
            control_number
    ) AS max

USING (
    control_number,
    date_updated
);

-- Get the 10 last signatures
SELECT
    petition_id,
    created_at

FROM
    signatures

ORDER BY
    created_at DESC

LIMIT 10;

-- GET the latest status for all petitions
SELECT
    ps.*
FROM
    petition_statuses ps
    INNER JOIN (


SELECT
    ANY_VALUE(MAX(ps.created_at)) as status_update,
