Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (1.6k points)
edited by

Below query works fine in mysql but it is showing error in Tableau. I checked with the Tableau community site and the only suggestion I got is to remove the semicolon from the code. I tried this but it is also not working. By connecting the database to Tableau I didn't have any problem. I can see the tables or the data. So how can I solve this problem?

SET @sql=NULL;

SELECT

Group_Concat(Distinct CONCAT(

'MAX(IF(wsd.cid = ''', wc.cid, ''', wsd.data, NULL)) AS    ''',wc.name,'',''''))

INTO @sql

FROM webform_component wc

WHERE wc.nid = 107;

SET @sql = Concat('SELECT wsd.sid,',@sql,'

FROM webform_submitted_data wsd

LEFT Join webform_component AS wc ON wsd.cid=wc.cid

WHERE wsd.nid = 107 AND wsd.sid >= 14967

GROUP BY wsd.sid');

PREPARE stmt FROM @sql;

EXECUTE stmt;

DEALLOCATE PREPARE stmt;

1 Answer

0 votes
by (3.1k points)
edited by

Tableau doesn't support these type of queries when you connect with mySQL. You should try to reformat this with nested subquery in Tableau.

 So the query should be a single query that will give a result set. Custom SQL query will be wrapped in subquery inside the Tableau. You will get the errors if your SQL can't be treated in that way.

 "initial SQL" allows you to run any SQL upfront, create temporary tables etc.

 After evaluation of initial SQL, you can write a query as a part of the connection and took advantage of the objects that are created in initial SQL.

To learn more about Tableau check tableau certification.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...