Hi All,

I have a problem with getting concatenated data in a query using “QueryResults” as the data source to combine queries that use two different DBs.
In detail:
First query from DB wich includes data about searches:
SELECT T_USER_SEARCH_HISTORY.id, T_USER_SEARCH_HISTORY.user_id, T_USER_SEARCH_HISTORY.created_date, WEEK(T_USER_SEARCH_HISTORY.created_date,3) KW, YEAR(T_USER_SEARCH_HISTORY.created_date) Year, CAST(CONCAT(YEAR(T_USER_SEARCH_HISTORY.created_date),"_",WEEK(T_USER_SEARCH_HISTORY.created_date,3)) as CHAR) CWYear

  • In the query combining the two data sources later I want to get CWYear

Second query gets data from a DB with Company information (nothing special here I guess)

Third query (the query using Query Results):
Select t1.id, t1.user_id, t1.created_date, t1.KW, t2.carrier, t1.Year, t1.CWYear
From query_572902 t1
Inner join cached_query_570346 t2
on t1.user_id = t2.id;

  • Here I simply want to get the data about the CWYear from my first query, but the results in this column are all zeros.

Any help how this could be solved would be much appreciated!

I find this usually comes down to bad type conversions. What happens if you explicitly CAST the ID fields into integers during the join?

Hi k4s1m,
thanks for your reply.
Sadly that did not help. I cased the ID fields during the join:
Select t1.id, t1.user_id, t1.created_date, t1.KW, t1.YearS, t1.CWYear, t2.carrier
From query_572902 t1
inner join cached_query_570346 t2
on CAST(t1.user_id AS INT) = CAST(t2.id AS INT);
But again did not get the CWYear data from t1:

In the query that creates the data for t1 (query_572902) everything works as expected:
Here the full query:
SELECT T_USER_SEARCH_HISTORY.id,
T_USER_SEARCH_HISTORY.user_id,
T_USER_SEARCH_HISTORY.created_date,
WEEK(T_USER_SEARCH_HISTORY.created_date,3) as “KW”,
YEAR(T_USER_SEARCH_HISTORY.created_date) as “YearS”,
CONCAT(CAST(YEAR(T_USER_SEARCH_HISTORY.created_date) AS DECIMAL),“_”,CAST(WEEK(T_USER_SEARCH_HISTORY.created_date,3) AS DECIMAL)) as “CWYear”
FROM T_USER_SEARCH_HISTORY
WHERE T_USER_SEARCH_HISTORY.created_by;

Calendar Week and year Concatenation works and gives these results:

Any other idea how to solve this?

This seems to be a Redash related bug.
I was not able to solve it in Redash, but noticed that the data actually appears like I want if I import it in google sheets.
In Redash:


In Google Sheets: