<?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>topic SQL Collector - alias and UNION queries in Community Chat</title>
    <link>https://systematic.workato.com/t5/community-chat/sql-collector-alias-and-union-queries/m-p/6718#M192</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;BR /&gt;as I could successfully run SQL queries (using Collection App) concerning SELECT of joined tables (managed as lists), I struggle when I want to refer to other elements I've already created inside the query.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;For example I can't make it concatenate 2 elements I've already created:&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;SELECT&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;field1 as [Name]&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;, field2 as [Surname]&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;, [Name] + [Surname] as [User]&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;...&lt;BR /&gt;in this occasion it'd return a "can't find Name column" error.&amp;nbsp;&lt;BR /&gt;Same thing I can face thus when trying creating a subquery to whom use a UNION.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;SELECT&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;T.field1&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;, T.field2...FROM (SELECT.....UNION SELECT....) as T&lt;BR /&gt;&lt;/STRONG&gt;&lt;/EM&gt;In this case I get pretty much the same error, having the system telling me that T.field1 cannot be found.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any suggestion to overcome these cases?&lt;BR /&gt;&lt;BR /&gt;Many thanks,&lt;BR /&gt;Eric&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2024 13:27:58 GMT</pubDate>
    <dc:creator>efiumano</dc:creator>
    <dc:date>2024-05-21T13:27:58Z</dc:date>
    <item>
      <title>SQL Collector - alias and UNION queries</title>
      <link>https://systematic.workato.com/t5/community-chat/sql-collector-alias-and-union-queries/m-p/6718#M192</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;BR /&gt;as I could successfully run SQL queries (using Collection App) concerning SELECT of joined tables (managed as lists), I struggle when I want to refer to other elements I've already created inside the query.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;For example I can't make it concatenate 2 elements I've already created:&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;SELECT&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;field1 as [Name]&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;, field2 as [Surname]&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;, [Name] + [Surname] as [User]&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;...&lt;BR /&gt;in this occasion it'd return a "can't find Name column" error.&amp;nbsp;&lt;BR /&gt;Same thing I can face thus when trying creating a subquery to whom use a UNION.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;SELECT&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;T.field1&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;, T.field2...FROM (SELECT.....UNION SELECT....) as T&lt;BR /&gt;&lt;/STRONG&gt;&lt;/EM&gt;In this case I get pretty much the same error, having the system telling me that T.field1 cannot be found.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any suggestion to overcome these cases?&lt;BR /&gt;&lt;BR /&gt;Many thanks,&lt;BR /&gt;Eric&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 13:27:58 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/sql-collector-alias-and-union-queries/m-p/6718#M192</guid>
      <dc:creator>efiumano</dc:creator>
      <dc:date>2024-05-21T13:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Collector - alias and UNION queries</title>
      <link>https://systematic.workato.com/t5/community-chat/sql-collector-alias-and-union-queries/m-p/6720#M193</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/10339"&gt;@efiumano&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In SQL, you cannot reference column aliases directly within the same SELECT&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;clause because the aliases are applied after the SELECT&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;clause is processed. Instead, you can try the below approach to achieve the desired result.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;SELECT
    field1 AS [Name],
    field2 AS [Surname],
    field1 + ' ' + field2 AS [User]
FROM
    your_table_name;&lt;/LI-CODE&gt;&lt;P&gt;we also have multiple ways to achieve this but, the above one is the more sufficient way to do it since your query doesn't have complex transformations&lt;/P&gt;&lt;P&gt;for the second issue,&amp;nbsp;If you are receiving an error stating that 'T.field1' cannot be found, ensure that 'T.field1'&amp;nbsp;exists in both 'table1'&amp;nbsp;and 'table2'&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;These techniques should help you overcome the errors you are facing.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Let me know if you find this helpful&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 16:56:15 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/sql-collector-alias-and-union-queries/m-p/6720#M193</guid>
      <dc:creator>Prajwal</dc:creator>
      <dc:date>2024-05-21T16:56:15Z</dc:date>
    </item>
  </channel>
</rss>

