<?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 Re: Dynamically specify pivot column in SQL in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/108158#M42985</link>
    <description>&lt;P&gt;Did u find any answer? Can u share your thoughts on meeting this usecase?&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2025 17:46:14 GMT</pubDate>
    <dc:creator>Wikram</dc:creator>
    <dc:date>2025-01-31T17:46:14Z</dc:date>
    <item>
      <title>Dynamically specify pivot column in SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/55225#M30273</link>
      <description>&lt;P&gt;Hello everyone !&lt;/P&gt;&lt;P&gt;I am looking for a way to dynamically specify pivot columns in a SQL query, so it can be used in a view. However we don't want to hard code the values that need to become columns, and would rather extract it from another table.&lt;/P&gt;&lt;P&gt;I've seen other posts on internet asking the same question but without any luck &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's what we have currently :&lt;/P&gt;&lt;PRE&gt;SELECT * FROM table PIVOT (&lt;SPAN&gt;sum(my_value)&lt;BR /&gt;FOR mapping in ('col1', 'col2', ...)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Instead we want to use a table &lt;STRONG&gt;table_mapping&amp;nbsp;containing all the values that should go in the list, is there any way to do that in sql ?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 07:50:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/55225#M30273</guid>
      <dc:creator>erigaud</dc:creator>
      <dc:date>2023-12-14T07:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically specify pivot column in SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/100769#M40416</link>
      <description>&lt;P&gt;I'm facing the same issue as you do, and apart from the Pyspark way (specifiying a `.groupBy(cols,...).pivot(col)`) and putting it in a view to query from SQL, I didn't find a convenient Spark SQL way of doing it.&lt;/P&gt;&lt;P&gt;Is there any plan to add a feature to get dynamic columns in SQL for Pivot on the Databricks side?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 14:20:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/100769#M40416</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2024-12-03T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically specify pivot column in SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/108158#M42985</link>
      <description>&lt;P&gt;Did u find any answer? Can u share your thoughts on meeting this usecase?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 17:46:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/108158#M42985</guid>
      <dc:creator>Wikram</dc:creator>
      <dc:date>2025-01-31T17:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically specify pivot column in SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/121262#M46394</link>
      <description>&lt;P&gt;I agree - not clear how to do this?&amp;nbsp; I'm thinking of using the pandas api.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 12:44:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dynamically-specify-pivot-column-in-sql/m-p/121262#M46394</guid>
      <dc:creator>lprevost</dc:creator>
      <dc:date>2025-06-09T12:44:52Z</dc:date>
    </item>
  </channel>
</rss>

