I’m trying to show a User Signup Dashboard, but I get December multiple times. What should I change?
I mean now I query user STATUS + USER_REGDATE
So isnt that wrong? I mean what if I have no signups in one month, then it just doesnt show me that month? I need to have a query where every Month is counted, and then Map these USER_REGDATE… hmmmm
the query can only show the data which is available so no signups means no data. Perhaps you could force all months with some sort of right join to a table containing all the month names. without more detail can’t be too specific
Isn’t there a different solution? Or maybe to use like variable or fake months as “query aliases”. I see that could be tricky with wappler. I mean is it a DB thing or more an APP thing … ?
How to put that strange query into Wappler…?
SELECT COUNT(u.userID) AS total, m.month
FROM (
SELECT 'Jan' AS MONTH
UNION SELECT 'Feb' AS MONTH
UNION SELECT 'Mar' AS MONTH
UNION SELECT 'Apr' AS MONTH
UNION SELECT 'May' AS MONTH
UNION SELECT 'Jun' AS MONTH
UNION SELECT 'Jul' AS MONTH
UNION SELECT 'Aug' AS MONTH
UNION SELECT 'Sep' AS MONTH
UNION SELECT 'Oct' AS MONTH
UNION SELECT 'Nov' AS MONTH
UNION SELECT 'Dec' AS MONTH
) AS m
LEFT JOIN users u
ON MONTH(STR_TO_DATE(CONCAT(m.month, ' 2013'),'%M %Y')) = MONTH(u.userRegistredDate)
AND YEAR(u.userRegistredDate) = '2013'
GROUP BY m.month
ORDER BY 1+1;
Pretty hard but common problem: Faking empty ranges…
I doubt it you could put this query into Wappler (it’s an example of why it would useful to have an ‘advanced’ option to write out own queries, including variables from Wappler - but I have no idea how feasible this would be).
I haven’t done what you’re trying to do in Wappler (or even MySQL), but I have come across similar situation and, like @Hyperbytes suggested, I would create a months table and get your totals from the other end as it were.
you create a view in the database then use it just like any table with wappler
i belive you can do it with PHP or with JS
you can create a table that have all the months in it too.
there is many ways to achieve the end goal. find what you like
Here is one simpler approach but I’ll try to figure it out with views …
select * from
(select 2000 as year union
select 2001 as year union
select 2009
) as years,
(select 1 as month union
select 2 as month union
select 3 as month union
select 4 as month union
select 5 as month union
select 6 as month union
select 7 as month union
select 8 as month union
select 9 as month
)
AS months
WHERE year between 2001 AND 2008 OR (year=2000 and month>0) OR (year = 2009 AND month < 4)
ORDER by year,month
BTW @George would it be possible to have more mysql functions like (https://www.w3schools.com/sql/sql_ref_mysql.asp) in Query Builder (now I only have SUM, AVG, COUNT, etc). I know thats maybe DB specific, as some people may use other DB types… or what you think? This question is a bit offtopic…
@Hyperbytes that is a very genius IDEA !!! I know exactly what you mean. So to have a JOIN which just uses all the MONTHS from that t_months and matches on the other side the specific registration dates ! I’m sure thats gonna work and with wappler clicky clicky GUI’s