Primarily want to know if what I’m attempting is not possible at this time in Metabase. I’m a hack when it comes to queries – at this time just trying to find a way to make it work
Goal is to calculate weekly growth as a percentage (week 2 # of users compared to week 1 # of users) given limited data within the table. The query currently works using MySQLWorkbench.
Anyone see something obvious below that would be causing the error? Appreciate any/all feedback.
Here’s the Query:
SET @runningTotal = 0;
SELECT
create_date,
concat(round(totals.num_accounts / @runningTotal * 100), '%') as percentGrowth,
@runningTotal := @runningTotal + totals.num_accounts AS runningTotal
FROM
(SELECT
DATE(Created_ts) AS create_date,
COUNT(*) AS num_accounts
FROM `db-name`.table-name AS u
Where Active != 'N'
GROUP BY weekofyear(u.created_ts)) totals
ORDER BY create_date;
Unfortunately it’s a quirk with the way the postgres connection works and we don’t have a clear fix at the moment. The work around is to unset the reporting timezone on the Settings page of the Admin Panel, that should prevent this error from happening.
I’d have to see the full query to give you a better sense of what’s going on. Postgres should be giving you back a better error message than that though
The only thing that I know doesn’t work in SQL queries is when you try to batch multiple statements together. So if you are writing a statement that ends with a semicolon, then writing another statement after it that won’t work. Otherwise we haven’t had any issues.