<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question SQL SELECT into Variable in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/SQL-SELECT-into-Variable/m-p/395246#M248902</link>
    <description>&lt;P&gt;There are two different examples of SQL in SQL Server&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1.&lt;/STRONG&gt; DECLARE &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id varchar(10)&lt;BR /&gt;SELECT &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id = MAX(date_id) FROM t_my_table&lt;BR /&gt;SELECT &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt; DECLARE &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id varchar(10) = (SELECT MAX(date_id) FROM t_my_table)&lt;BR /&gt;SELECT &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id&lt;/P&gt;&lt;P&gt;How can I do the same thing in "Impala Query Manager"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2026 06:24:50 GMT</pubDate>
    <dc:creator>AKO</dc:creator>
    <dc:date>2026-04-21T06:24:50Z</dc:date>
    <item>
      <title>SQL SELECT into Variable</title>
      <link>https://community.cloudera.com/t5/Support-Questions/SQL-SELECT-into-Variable/m-p/395246#M248902</link>
      <description>&lt;P&gt;There are two different examples of SQL in SQL Server&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1.&lt;/STRONG&gt; DECLARE &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id varchar(10)&lt;BR /&gt;SELECT &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id = MAX(date_id) FROM t_my_table&lt;BR /&gt;SELECT &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt; DECLARE &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id varchar(10) = (SELECT MAX(date_id) FROM t_my_table)&lt;BR /&gt;SELECT &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/25407"&gt;@Max&lt;/a&gt;_date_id&lt;/P&gt;&lt;P&gt;How can I do the same thing in "Impala Query Manager"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 06:24:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/SQL-SELECT-into-Variable/m-p/395246#M248902</guid>
      <dc:creator>AKO</dc:creator>
      <dc:date>2026-04-21T06:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: SQL SELECT into Variable</title>
      <link>https://community.cloudera.com/t5/Support-Questions/SQL-SELECT-into-Variable/m-p/395251#M248904</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/118846"&gt;@AKO&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Impala has variable substitution like this:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="s1"&gt;[hostname.local.net:21000] default&amp;gt; SET VAR:query=SELECT 1+2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;Variable QUERY set to SELECT 1+2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;[hostname.local.net:21000] default&amp;gt; ${VAR:query};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;Query: SELECT 1+2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;Query submitted at: 2024-10-15 15:54:29 (Coordinator: https://hostname.local.net:25000)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;Query progress can be monitored at: https://hostname.local.net:25000/query_plan?query_id=nnnn&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;+-------+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;| 1 + 2 |&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;+-------+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;| 3 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;+-------+&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="s1"&gt;Fetched 1 row(s) in 1.15s&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;See official Impala docs at:&lt;BR /&gt;&lt;SPAN&gt;&lt;A href="https://impala.apache.org/docs/build/html/topics/impala_shell_running_commands.html" target="_blank" rel="noopener"&gt;https://impala.apache.org/docs/build/html/topics/impala_shell_running_commands.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is a feature of impala-shell, and not impala itself, so depending on what you call&amp;nbsp;"Impala Query Manager", your experience might be different.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you want a solution that is more database independent, then I recommend to use a view or a SELECT CTE (WITH statement) instead:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;WITH sub_query AS (&lt;BR /&gt;    SELECT 1+2&lt;BR /&gt;)&lt;BR /&gt;SELECT * FROM sub_query;&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2024 16:03:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/SQL-SELECT-into-Variable/m-p/395251#M248904</guid>
      <dc:creator>zegab</dc:creator>
      <dc:date>2024-10-15T16:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: SQL SELECT into Variable</title>
      <link>https://community.cloudera.com/t5/Support-Questions/SQL-SELECT-into-Variable/m-p/395259#M248905</link>
      <description>&lt;P&gt;I know about CTE solution I was trying to find if the variable like SQL Server solution is there or not. I will use CTE. thanks&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 17:03:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/SQL-SELECT-into-Variable/m-p/395259#M248905</guid>
      <dc:creator>AKO</dc:creator>
      <dc:date>2024-10-15T17:03:33Z</dc:date>
    </item>
  </channel>
</rss>

