The WITH clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.
It helps break down complicated and large queries into simpler, easily readable forms and proves especially useful when the subquery is executed multiple times. It computes the aggregation once and can then be repeatedly referenced by its name in the queries.CTEs can reference each other and can be nested. The WITH clause must be defined before it’s used in the query.Here is the basic syntax of a SELECT statement with the optional WITH clause:
WITH name_for_summary_data AS (SELECT statement)SELECT columnsFROM name_for_summary_data
Basic CTE examples:
-- create a CTE called "cte" and use it in the main queryWITH cte AS (SELECT 35 AS x)SELECT * FROM cte;┌────┐│ x │├────┤│ 35 │└────┘
-- create two CTEs, where the second CTE references the first CTEWITH cte AS (SELECT 35 AS i), cte2 AS (SELECT i*100 AS x FROM cte)SELECT * FROM cte2;┌──────┐│ x │├──────┤│ 3500 │└──────┘
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"RisingWave","colors":{"primary":"#005eec","light":"#005eec","dark":"#005eec"},"logo":{"light":"https://mintcdn.com/risingwavelabs/MBiw07hESa08PLsp/logo/light.svg?fit=max\u0026auto=format\u0026n=MBiw07hESa08PLsp\u0026q=85\u0026s=ec9c31744f8c3ddaa5c37f6f7fd0385b","dark":"https://mintcdn.com/risingwavelabs/MBiw07hESa08PLsp/logo/dark.svg?fit=max\u0026auto=format\u0026n=MBiw07hESa08PLsp\u0026q=85\u0026s=5faa0cc3c55a9407df9bb353ee579e89","href":"https://risingwave.com/"},"favicon":"https://mintcdn.com/risingwavelabs/eqqtg34aUutkXCuz/favicon.png?fit=max\u0026auto=format\u0026n=eqqtg34aUutkXCuz\u0026q=85\u0026s=32d724d78a6ff3342f31bed536427c8f","background":{"decoration":"gradient"},"navbar":{"links":[{"href":"https://risingwave.com/resources/?filter=blogs","label":"Blog"}],"primary":{"type":"button","label":"Sign up free","href":"https://cta-service-cms2.hubspot.com/web-interactives/public/v1/track/redirect?encryptedPayload=AVxigLIVNzabNcOPWI6bnbgE5v5wBhWy6pk6dNZ0jpoHYTJVXYdKJ2sN2%2Bz81tvbqU9obUFnA6qJBV3VfxEI3LOXQz%2FR1xANlR5nhw9CzFWt250u2%2B%2FfsHip8lVRCRiV%2FX0l10HpM%2BZWdr%2FmPAe%2BTHYRotiKZ1nJ494JNXcirwOZXbhlh5RTBgXXdxwxHyst\u0026webInteractiveContentId=183953770777\u0026portalId=24308934"}},"footer":{"socials":{"github":"https://github.com/risingwavelabs/risingwave","x":"https://go.risingwave.com/twitter","linkedin":"https://go.risingwave.com/linkedin","slack":"https://go.risingwave.com/slack","youtube":"https://go.risingwave.com/youtube"}},"fonts":{"heading":{"family":"Inter","format":"woff2"},"body":{"family":"Inter","format":"woff2"}},"integrations":{"ga4":{"measurementId":"G-VG98SVDEYE"},"gtm":{"tagId":"GTM-WT9WLCBX"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"styling":{"latex":true},"navigation":{"global":{"anchors":[{"anchor":"Join Slack community","icon":"slack","href":"https://go.risingwave.com/slack"},{"anchor":"GitHub","icon":"github","href":"https://github.com/risingwavelabs/risingwave"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"risingwavelabs","hasAudioNarration":false,"actualSubdomain":"risingwavelabs","customDomains":["docs.risingwave.com"],"gitSource":{"type":"github","owner":"risingwavelabs","repo":"risingwave-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6aeab300d48611d74e22bb8d","collectionId":"d3dae305-a08d-4613-a335-8c5568f20672","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6aeab300d48611d74e22bb8d"},"feedback":{"thumbs":true,"edits":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aed242fed8341fabea21e61","clientVersion":"0.0.4074","searchFilterCounts":[{"language":"default","tag":"Guides","count":279},{"language":"default","tag":"SQL/Python/UDFs","count":156},{"language":"default","tag":"SQL reference","count":148},{"language":"default","tag":"Work with data","count":117},{"language":"default","tag":"Commands","count":99},{"language":"default","tag":"Cloud","count":67},{"language":"default","tag":"Ingest data","count":52},{"language":"default","tag":"Apache Iceberg™","count":37},{"language":"default","tag":"Deliver data","count":35},{"language":"default","tag":"Install \u0026 Operate","count":32}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"styles.css","content":"@font-face{font-family:'Monument Grotesk';src:url('https://fonts.gstatic.com/s/inter/v18/UcCo3FwrK3iLTcviYwYZ8UA3.woff2');font-weight:normal;font-style:normal;font-display:swap}h1,h2,h3{font-family:'monument grotesk';letter-spacing:normal!important}"}],"page":{"pagePath":"sql/query-syntax/with-clause","slug":"/sql/query-syntax/with-clause","pageMetadata":{"title":"WITH clause","description":"The `WITH` clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.","href":"/sql/query-syntax/with-clause"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx, jsxs: _jsxs} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n code: \"code\",\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsxs(_components.p, {\n children: [\"The \", _jsx(_components.code, {\n children: \"WITH\"\n }), \" clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.\"]\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`It helps break down complicated and large queries into simpler, easily readable forms and proves especially useful when the subquery is executed multiple times. It computes the aggregation once and can then be repeatedly referenced by its name in the queries.`}),`\n`,_jsxs(_components.p,{children:[`CTEs can reference each other and can be nested. The `,_jsx(_components.code,{children:`WITH`}),` clause must be defined before it’s used in the query.`]}),`\n`,_jsxs(_components.p,{children:[`Here is the basic syntax of a `,_jsx(_components.code,{children:`SELECT`}),` statement with the optional `,_jsx(_components.code,{children:`WITH`}),` clause:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`WITH`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` name_for_summary_data `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` statement`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` columns`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` name_for_summary_data`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Basic CTE examples:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`-- create a CTE called \"cte\" and use it in the main query`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`WITH`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cte `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 35`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` x)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cte;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`┌────┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`│ x │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`├────┤`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`│ `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`35`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` │`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`└────┘`})}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`9`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`-- create two CTEs, where the second CTE references the first CTE`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`WITH`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cte `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 35`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` i),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cte2 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` i`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`100`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` x `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cte)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cte2;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`┌──────┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`│ x │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`├──────┤`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`│ `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3500`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` │`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`└──────┘`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"WITH clause","description":"The `WITH` clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.","href":"/sql/query-syntax/with-clause"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"subdomain":"risingwavelabs","siteName":"RisingWave","title":"WITH clause - RisingWave","navMaps":{"firstHrefInVersion":{"Current (v3.0)":{"href":"/sql/query-syntax/with-clause","matchLevel":0}},"firstHrefInLanguage":{}},"lastModified":"2026-01-22T08:22:17.568Z","originalFileLocation":"sql/query-syntax/with-clause.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"The WITH clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.\">\u003cmeta data-mint-head name=\"application-name\" content=\"RisingWave\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"WITH clause - RisingWave\">\u003cmeta data-mint-head property=\"og:description\" content=\"The WITH clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"RisingWave\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.risingwave.com/sql/query-syntax/with-clause\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://risingwavelabs.mintlify.site/_mintlify/api/og/v2?division=Query+syntax\u0026amp;title=WITH+clause\u0026amp;description=The+%60WITH%60+clause+provides+a+way+to+write+supplemental+statements+for+a+larger+query.+These+statements%2C+also+known+as+Common+Table+Expressions+or+CTEs%2C+can+be+v\u0026amp;theme=f623197ed300707840b7cb4e\u0026amp;signature=0a5b7aefb21e8259a001875ef3bbade4845c75a7117b9c14915a432e1af1128b\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"WITH clause - RisingWave\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"The WITH clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://risingwavelabs.mintlify.site/_mintlify/api/og/v2?division=Query+syntax\u0026amp;title=WITH+clause\u0026amp;description=The+%60WITH%60+clause+provides+a+way+to+write+supplemental+statements+for+a+larger+query.+These+statements%2C+also+known+as+Common+Table+Expressions+or+CTEs%2C+can+be+v\u0026amp;theme=f623197ed300707840b7cb4e\u0026amp;signature=0a5b7aefb21e8259a001875ef3bbade4845c75a7117b9c14915a432e1af1128b\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/risingwavelabs/XB2VPvZUQ1sTe2fS/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"RisingWave\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#005eec\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.risingwave.com/sql/query-syntax/with-clause\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/sql/query-syntax/with-clause.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.risingwave.com/#organization\",\"name\":\"RisingWave\",\"url\":\"https://docs.risingwave.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/risingwavelabs/MBiw07hESa08PLsp/logo/light.svg?fit=max\u0026auto=format\u0026n=MBiw07hESa08PLsp\u0026q=85\u0026s=ec9c31744f8c3ddaa5c37f6f7fd0385b\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.risingwave.com#website\",\"name\":\"RisingWave\",\"url\":\"https://docs.risingwave.com\",\"publisher\":{\"@id\":\"https://docs.risingwave.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.risingwave.com/sql/query-syntax/with-clause#webpage\",\"url\":\"https://docs.risingwave.com/sql/query-syntax/with-clause\",\"name\":\"WITH clause\",\"description\":\"The WITH clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.\",\"dateModified\":\"2026-01-22T08:22:17.568Z\",\"isPartOf\":{\"@id\":\"https://docs.risingwave.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.risingwave.com/sql/query-syntax/with-clause#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.risingwave.com/sql/query-syntax/with-clause#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"SQL reference\",\"item\":\"https://docs.risingwave.com/sql/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Query syntax\",\"item\":\"https://docs.risingwave.com/sql/query-syntax/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"WITH clause\",\"item\":\"https://docs.risingwave.com/sql/query-syntax/with-clause\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.risingwave.com/sql/query-syntax/with-clause#article\",\"headline\":\"WITH clause\",\"name\":\"WITH clause\",\"description\":\"The WITH clause provides a way to write supplemental statements for a larger query. These statements, also known as Common Table Expressions or CTEs, can be viewed as defining temporary tables that exist just for one query.\",\"url\":\"https://docs.risingwave.com/sql/query-syntax/with-clause\",\"mainEntityOfPage\":{\"@id\":\"https://docs.risingwave.com/sql/query-syntax/with-clause#webpage\"},\"dateModified\":\"2026-01-22T08:22:17.568Z\",\"publisher\":{\"@id\":\"https://docs.risingwave.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.risingwave.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"RisingWave\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"RisingWave","nav":{"global":{"anchors":[{"anchor":"Join Slack community","icon":"slack","href":"https://go.risingwave.com/slack"},{"anchor":"GitHub","icon":"github","href":"https://github.com/risingwavelabs/risingwave"}]},"versions":[{"version":"Current (v3.0)","tabs":[{"tab":"Guides","pages":[{"title":"Guides","href":"/get-started/intro"}]},{"tab":"Apache Iceberg™","pages":[{"title":"Apache Iceberg™","href":"/iceberg/overview"}]},{"tab":"SQL/Python/UDFs","groups":[{"group":"SQL reference","pages":[{"title":"SQL reference","sidebarTitle":"Overview","mode":"wide","href":"/sql/overview"},{"group":"Commands","pages":[{"title":"SQL commands","mode":"wide","sidebarTitle":"Overview","href":"/sql/commands/overview"},{"title":"ALTER CONNECTION","href":"/sql/commands/sql-alter-connection"},{"title":"ALTER DEFAULT PRIVILEGES","href":"/sql/commands/sql-alter-default-privileges"},{"title":"ALTER DATABASE","href":"/sql/commands/sql-alter-database"},{"title":"ALTER FRAGMENT","sidebarTitle":"ALTER FRAGMENT","href":"/sql/commands/sql-alter-fragment"},{"title":"ALTER FUNCTION","href":"/sql/commands/sql-alter-function"},{"title":"ALTER INDEX","href":"/sql/commands/sql-alter-index"},{"title":"ALTER MATERIALIZED VIEW","href":"/sql/commands/sql-alter-materialized-view"},{"title":"ALTER SCHEMA","href":"/sql/commands/sql-alter-schema"},{"title":"ALTER SECRET","href":"/sql/commands/sql-alter-secret"},{"title":"ALTER SINK","href":"/sql/commands/sql-alter-sink"},{"title":"ALTER SOURCE","href":"/sql/commands/sql-alter-source"},{"title":"ALTER SUBSCRIPTION","href":"/sql/commands/sql-alter-subscription"},{"title":"ALTER SWAP","href":"/sql/commands/sql-alter-swap"},{"title":"ALTER SYSTEM","href":"/sql/commands/sql-alter-system"},{"title":"ALTER TABLE","href":"/sql/commands/sql-alter-table"},{"title":"ALTER USER","href":"/sql/commands/sql-alter-user"},{"title":"ALTER VIEW","href":"/sql/commands/sql-alter-view"},{"title":"AS CHANGELOG","href":"/sql/commands/sql-as-changelog"},{"title":"BEGIN","href":"/sql/commands/sql-begin"},{"title":"CANCEL JOBS","href":"/sql/commands/sql-cancel-jobs"},{"title":"COMMENT ON","href":"/sql/commands/sql-comment-on"},{"title":"COMMIT","href":"/sql/commands/sql-commit"},{"title":"COPY","href":"/sql/commands/sql-copy"},{"title":"CREATE AGGREGATE","href":"/sql/commands/sql-create-aggregate"},{"title":"CREATE CONNECTION","href":"/sql/commands/sql-create-connection"},{"title":"CREATE DATABASE","href":"/sql/commands/sql-create-database"},{"title":"CREATE FUNCTION","href":"/sql/commands/sql-create-function"},{"title":"CREATE INDEX","href":"/sql/commands/sql-create-index"},{"title":"CREATE MATERIALIZED VIEW","sidebarTitle":"CREATE MATERIALIZED VIEW","href":"/sql/commands/sql-create-mv"},{"title":"CREATE SCHEMA","href":"/sql/commands/sql-create-schema"},{"title":"CREATE SECRET","href":"/sql/commands/sql-create-secret"},{"title":"CREATE SINK INTO","href":"/sql/commands/sql-create-sink-into"},{"title":"CREATE SINK","href":"/sql/commands/sql-create-sink"},{"title":"CREATE SOURCE","href":"/sql/commands/sql-create-source"},{"title":"CREATE TABLE","href":"/sql/commands/sql-create-table"},{"title":"CREATE USER","href":"/sql/commands/sql-create-user"},{"title":"CREATE VIEW","href":"/sql/commands/sql-create-view"},{"title":"DELETE","href":"/sql/commands/sql-delete"},{"title":"DESCRIBE","href":"/sql/commands/sql-describe"},{"title":"DISCARD","href":"/sql/commands/sql-discard"},{"title":"DROP AGGREGATE","href":"/sql/commands/sql-drop-aggregate"},{"title":"DROP CONNECTION","href":"/sql/commands/sql-drop-connection"},{"title":"DROP DATABASE","href":"/sql/commands/sql-drop-database"},{"title":"DROP FUNCTION","href":"/sql/commands/sql-drop-function"},{"title":"DROP INDEX","href":"/sql/commands/sql-drop-index"},{"title":"DROP MATERIALIZED VIEW","href":"/sql/commands/sql-drop-mv"},{"title":"DROP SCHEMA","href":"/sql/commands/sql-drop-schema"},{"title":"DROP SECRET","href":"/sql/commands/sql-drop-secret"},{"title":"DROP SINK","href":"/sql/commands/sql-drop-sink"},{"title":"DROP SOURCE","href":"/sql/commands/sql-drop-source"},{"title":"DROP TABLE","href":"/sql/commands/sql-drop-table"},{"title":"DROP USER","href":"/sql/commands/sql-drop-user"},{"title":"DROP VIEW","href":"/sql/commands/sql-drop-view"},{"title":"EXPLAIN","href":"/sql/commands/sql-explain"},{"title":"EXPLAIN ANALYZE","href":"/sql/commands/sql-explain-analyze"},{"title":"FLUSH","href":"/sql/commands/sql-flush"},{"title":"GRANT","href":"/sql/commands/sql-grant"},{"title":"INSERT","href":"/sql/commands/sql-insert"},{"title":"RECOVER","href":"/sql/commands/sql-recover"},{"title":"REFRESH TABLE","href":"/sql/commands/sql-refresh-table"},{"title":"REPLACE SINK","href":"/sql/commands/sql-replace-sink"},{"title":"REVOKE","href":"/sql/commands/sql-revoke"},{"title":"SELECT","href":"/sql/commands/sql-select"},{"title":"SET BACKGROUND_DDL","href":"/sql/commands/sql-set-background-ddl"},{"title":"SET DML_WAIT_PERSISTENCE","href":"/sql/commands/sql-set-dml-wait-persistence"},{"title":"SET RW_IMPLICIT_FLUSH","href":"/sql/commands/sql-set-rw-implicit-flush"},{"title":"SET TIME ZONE","href":"/sql/commands/sql-set-time-zone"},{"title":"SET","href":"/sql/commands/sql-set"},{"title":"SHOW CLUSTER","href":"/sql/commands/sql-show-cluster"},{"title":"SHOW COLUMNS","href":"/sql/commands/sql-show-columns"},{"title":"SHOW CONNECTIONS","href":"/sql/commands/sql-show-connections"},{"title":"SHOW CREATE INDEX","href":"/sql/commands/sql-show-create-index"},{"title":"SHOW CREATE MATERIALIZED VIEW","href":"/sql/commands/sql-show-create-mv"},{"title":"SHOW CREATE SINK","href":"/sql/commands/sql-show-create-sink"},{"title":"SHOW CREATE SOURCE","href":"/sql/commands/sql-show-create-source"},{"title":"SHOW CREATE TABLE","href":"/sql/commands/sql-show-create-table"},{"title":"SHOW CREATE VIEW","href":"/sql/commands/sql-show-create-view"},{"title":"SHOW CURSORS","href":"/sql/commands/sql-show-cursors"},{"title":"SHOW DATABASES","href":"/sql/commands/sql-show-databases"},{"title":"SHOW FUNCTIONS","href":"/sql/commands/sql-show-functions"},{"title":"SHOW INDEXES","href":"/sql/commands/sql-show-indexes"},{"title":"SHOW INTERNAL TABLES","href":"/sql/commands/sql-show-internal-tables"},{"title":"SHOW JOBS","href":"/sql/commands/sql-show-jobs"},{"title":"SHOW MATERIALIZED VIEWS","href":"/sql/commands/sql-show-mv"},{"title":"SHOW PARAMETERS","href":"/sql/commands/sql-show-parameters"},{"title":"SHOW PROCESSLIST","href":"/sql/commands/sql-show-processlist"},{"title":"SHOW SCHEMAS","href":"/sql/commands/sql-show-schemas"},{"title":"SHOW SECRETS","href":"/sql/commands/sql-show-secrets"},{"title":"SHOW SINKS","href":"/sql/commands/sql-show-sinks"},{"title":"SHOW SOURCES","href":"/sql/commands/sql-show-sources"},{"title":"SHOW SUBSCRIPTIONS","href":"/sql/commands/sql-show-subscriptions"},{"title":"SHOW SUBSCRIPTION CURSORS","href":"/sql/commands/sql-show-subscription-cursors"},{"title":"SHOW TABLES","href":"/sql/commands/sql-show-tables"},{"title":"SHOW VIEWS","href":"/sql/commands/sql-show-views"},{"title":"START TRANSACTION","href":"/sql/commands/sql-start-transaction"},{"title":"UPDATE","href":"/sql/commands/sql-update"},{"title":"VACUUM","href":"/sql/commands/sql-vacuum"},{"title":"WAIT","href":"/sql/commands/sql-wait"}]},{"group":"Query syntax","pages":[{"title":"Query syntax","sidebarTitle":"Overview","href":"/sql/query-syntax/overview"},{"title":"Literals","href":"/sql/query-syntax/literals"},{"title":"Value expressions","href":"/sql/query-syntax/value-exp"},{"title":"Generated columns","href":"/sql/query-syntax/generated-columns"},{"title":"FROM clause","href":"/sql/query-syntax/from-clause"},{"title":"WHERE clause","href":"/sql/query-syntax/where-clause"},{"title":"GROUP BY clause","href":"/sql/query-syntax/group-by-clause"},{"title":"HAVING clause","href":"/sql/query-syntax/having-clause"},{"title":"ORDER BY clause","href":"/sql/query-syntax/order-by-clause"},{"title":"LIMIT clause","mode":"wide","href":"/sql/query-syntax/limit-clause"},{"title":"VALUES clause","href":"/sql/query-syntax/values-clause"},{"title":"Set operations","description":"The results of two queries can be combined using the set operations `UNION` and `INTERSECT`.","href":"/sql/query-syntax/set-operations"},{"title":"WITH clause","href":"/sql/query-syntax/with-clause"},{"title":"WITH ORDINALITY clause","description":"The `WITH ORDINALITY` clause can be used with set functions in the `FROM` clause of a query.","href":"/sql/query-syntax/with-ordinality-clause"}]},{"group":"Data types","pages":[{"title":"Overview of data types","sidebarTitle":"Overview","href":"/sql/data-types/overview"},{"title":"Casting","mode":"wide","href":"/sql/data-types/casting"},{"title":"Struct","href":"/sql/data-types/struct"},{"title":"ARRAY type","sidebarTitle":"Array","href":"/sql/data-types/array-type"},{"title":"Map type","sidebarTitle":"Map","href":"/sql/data-types/map-type"},{"title":"JSONB","href":"/sql/data-types/jsonb"},{"title":"VARIANT","href":"/sql/data-types/variant"},{"title":"rw_int256","href":"/sql/data-types/rw-int256"},{"title":"Vector data type","sidebarTitle":"Vector","href":"/sql/data-types/vector"},{"title":"Supported protobuf types","sidebarTitle":"Protobuf","href":"/sql/data-types/supported-protobuf-types"}]},{"group":"Functions and operators","pages":[{"title":"SQL functions and operators","sidebarTitle":"Overview","mode":"wide","href":"/sql/functions/overview"},{"title":"Logical operators","mode":"wide","href":"/sql/functions/logical"},{"title":"Comparison functions and operators","href":"/sql/functions/comparison"},{"title":"Mathematical functions and operators","href":"/sql/functions/mathematical"},{"title":"String functions and operators","href":"/sql/functions/string"},{"title":"Binary string functions and operators","href":"/sql/functions/binarystring"},{"title":"Date and time functions and operators","href":"/sql/functions/datetime"},{"title":"Cryptographic functions","href":"/sql/functions/cryptographic"},{"title":"JSON functions and operators","href":"/sql/functions/json"},{"title":"Array functions and operators","href":"/sql/functions/array"},{"title":"Map functions and operators","href":"/sql/functions/map"},{"title":"Conditional expressions","href":"/sql/functions/conditional"},{"title":"Aggregate functions","href":"/sql/functions/aggregate"},{"title":"Window functions","href":"/sql/functions/window-functions"},{"title":"Set-returning functions","href":"/sql/functions/set-returning"},{"title":"System administration functions","href":"/sql/functions/sys-admin"},{"title":"System information functions","href":"/sql/functions/sys-info"},{"title":"AI functions","href":"/sql/functions/ai"}]},{"title":"Identifiers","href":"/sql/identifiers"},{"group":"System catalogs","pages":[{"title":"System catalogs","sidebarTitle":"Overview","mode":"wide","href":"/sql/system-catalogs/overview"},{"title":"Information schema","href":"/sql/system-catalogs/information-schema"},{"title":"PostgreSQL catalogs","href":"/sql/system-catalogs/pg-catalog"},{"title":"RisingWave catalogs","href":"/sql/system-catalogs/rw-catalog"}]},{"title":"Psql commands","mode":"wide","href":"/sql/psql-commands"}]},{"group":"Python SDK","pages":[{"title":"Python SDK","href":"/sql/python-sdk/intro"}]},{"group":"User-defined functions","pages":[{"title":"User-defined functions","sidebarTitle":"Overview","href":"/sql/udfs/user-defined-functions"},{"group":"External UDFs","pages":[{"title":"External Python UDFs","sidebarTitle":"Python","href":"/sql/udfs/use-udfs-in-python"},{"title":"External Java UDFs","sidebarTitle":"Java","href":"/sql/udfs/use-udfs-in-java"}]},{"group":"Embedded UDFs","pages":[{"title":"Embedded Python UDFs","sidebarTitle":"Python","href":"/sql/udfs/embedded-python-udfs"},{"title":"Use UDFs in JavaScript","sidebarTitle":"JavaScript","href":"/sql/udfs/use-udfs-in-javascript"},{"title":"Use UDFs in Rust","sidebarTitle":"Rust","href":"/sql/udfs/use-udfs-in-rust"}]},{"title":"SQL UDFs","href":"/sql/udfs/sql-udfs"}]}]},{"tab":"Client Libraries","pages":[{"title":"Client Libraries","href":"/client-libraries/overview"}]},{"tab":"Web UI","pages":[{"title":"Web UI","href":"/web-ui/introduction"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog/release-notes"}]}]}]},"basePath":"","title":"WITH clause - RisingWave","buildId":"dpl_BLQvU86QFwq3AhPofSTw6q8dGWKm","deploymentId":"dpl_BLQvU86QFwq3AhPofSTw6q8dGWKm","dynamics":[],"chunks":[]}