What I want to do is add a second line for the average. I know I must do that in my query but can’t figure out the proper syntax. Here is my Query …
SELECT
joborders.JODateRec AS Work_Date,
COUNT( joborders.JODateRec ) AS Job_Orders
FROM
joborders
WHERE
joborders.JODateRec >= NOW() - INTERVAL 28 DAY
GROUP BY
joborders.JODateRec
ORDER BY
joborders.JODateRec
Thanks Max, that was my first thought as well. But that just gives me a date value. I need the average of the COUNT value. Average seems to be missing from the ‘Format Number’ features in Wappler as well. But that’s for another thread.
Average number of orders per day. Graph shows total orders per day. I’d like to if possible add a second data set to show the average number of orders per day over that period.
Yes, that is what I am trying to achieve but can’t figure out the SQL for it. It’s the grouping that is screwing me up.
SELECT
joborders.JODateRec AS Work_Date,
COUNT( joborders.JODateRec ) AS Job_Orders
FROM
joborders
WHERE
joborders.JODateRec >= NOW() - INTERVAL 28 Day
GROUP BY
joborders.JODateRec
ORDER BY
joborders.JODateRec
Gets me the line I need for number of job orders each day.
SELECT
COUNT( joborders.JODateRec ) AS Job_Orders,
COUNT(*)/ COUNT(
DISTINCT DATE( joborders.JODateRec )) AS Average
FROM
joborders
WHERE
joborders.JODateRec >= NOW() - INTERVAL 28 DAY
ORDER BY
joborders.JODateRec
Gets me the right average but I can’t combine the two queries. I may just admit to boss it can’t be done.
Hi Brad,
You can do it in a bit “hacky” way, not hard to do though.
If your server action component in App Connect is called serverconnect1 and your query query1 then you just add another data set in the charts and use this as its value: