<?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: Update on CTE in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/update-on-cte/m-p/96972#M8670</link>
    <description>&lt;P&gt;An actual "Update", it may not be possible, but have you consider and will something like this work for you? This is simulating updates within the query without actual UPDATE statements:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;CREATE OR REPLACE TABLE table1 AS
WITH CTE1 AS (
    -- Your initial query for CTE1
),
CTE2 AS (
    SELECT 
        CASE WHEN condition THEN updated_value ELSE original_value END AS column_name,
        ...
    FROM CTE1
),
CTE3 AS (
    SELECT *
    FROM CTE2
)
SELECT *
FROM CTE3;&lt;/LI-CODE&gt;
&lt;P&gt;Feel free to clarify if there's a misunderstanding about the requirement. Meanwhile, hope it helps.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2024 11:27:12 GMT</pubDate>
    <dc:creator>VZLA</dc:creator>
    <dc:date>2024-10-31T11:27:12Z</dc:date>
    <item>
      <title>Update on CTE</title>
      <link>https://community.databricks.com/t5/get-started-discussions/update-on-cte/m-p/96885#M8669</link>
      <description>&lt;P&gt;So&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am reflecting a business logic from on prem to azure databricks .&amp;nbsp;&lt;BR /&gt;what on prem did is&amp;nbsp;&lt;/P&gt;&lt;P&gt;created the table and after that updated .&amp;nbsp;&lt;BR /&gt;I have to construct that as a single query .&amp;nbsp;&lt;BR /&gt;Example&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create or replace table table1&lt;/P&gt;&lt;P&gt;with CTE 1 as (&lt;/P&gt;&lt;P&gt;) ,&lt;/P&gt;&lt;P&gt;CTE 2 as (&lt;/P&gt;&lt;P&gt;select some columns from cte1&lt;/P&gt;&lt;P&gt;) ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;CTE 3 as (&lt;/P&gt;&lt;P&gt;select some columns from CTE2&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;select * from CTE3&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but there are some updates from on prem which I need to apply to CTE2 .&amp;nbsp;&lt;BR /&gt;can I apply those updates after CTE2 before CTE 3 ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&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>Wed, 30 Oct 2024 21:13:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/update-on-cte/m-p/96885#M8669</guid>
      <dc:creator>MC97</dc:creator>
      <dc:date>2024-10-30T21:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Update on CTE</title>
      <link>https://community.databricks.com/t5/get-started-discussions/update-on-cte/m-p/96972#M8670</link>
      <description>&lt;P&gt;An actual "Update", it may not be possible, but have you consider and will something like this work for you? This is simulating updates within the query without actual UPDATE statements:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;CREATE OR REPLACE TABLE table1 AS
WITH CTE1 AS (
    -- Your initial query for CTE1
),
CTE2 AS (
    SELECT 
        CASE WHEN condition THEN updated_value ELSE original_value END AS column_name,
        ...
    FROM CTE1
),
CTE3 AS (
    SELECT *
    FROM CTE2
)
SELECT *
FROM CTE3;&lt;/LI-CODE&gt;
&lt;P&gt;Feel free to clarify if there's a misunderstanding about the requirement. Meanwhile, hope it helps.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 11:27:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/update-on-cte/m-p/96972#M8670</guid>
      <dc:creator>VZLA</dc:creator>
      <dc:date>2024-10-31T11:27:12Z</dc:date>
    </item>
  </channel>
</rss>

