When using the Advanced mode of Query to Grid Variable, the 'order by' of my SQL query is not maintained.
When I run the query in Snowflake the order is as I have specified but when I "sample" or run the Query to Grid Variable component using the same query, the results are all over the place.
My query is using 'union' to smash some results into rows.
Another irritating inconsistency in Matillion.
Here is the SQL:
<code>
select 'SURVEY_ID' as cols, 0 as page_id, 1 as question_order union
select 'QUESTION_ID' as cols, 0 as page_id, 2 as question_order union
select 'RESPONSE_ID' as cols, 0 as page_id, 3 as question_order union
select 'RESPONSE_WEIGHT' as cols, 0 as page_id, 4 as question_order union
select 'RESPONSE_STATUS' as cols, 0 as page_id, 5 as question_order union
select 'RESPONSE_DATE_CREATED' as cols, 0 as page_id, 6 as question_order union
select
case when response_answer_secondary is not null then concat(response_question_text,'|',response_answer_primary)
else response_question_text
end as cols,
q.page_id, q.question_order
from research.survey_responses r
left join research.survey_questions q on r.question_id = q.question_id
where r.survey_id = 507570715
order by page_id, question_order
</ code>