AI Squared’s SQL Editor allows you to define and manage your data models directly through SQL queries. This powerful tool supports native SQL commands compatible with your data warehouse, enabling you to seamlessly model your data.
Click the Preview button to review the first 100 rows of your data. This step ensures the query fetches the expected data. After verifying, proceed by clicking Continue.
Important Note: The model cannot be saved if the query is incorrect or yields no results.
SELECT *FROM your_datasetWHERE important_column1 IS NOT NULL AND important_column2 IS NOT NULL
Replace important_column1, important_column2, etc., with your relevant column names.
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"AI Squared","colors":{"primary":"#00249c","light":"#ffffff","dark":"#00249c"},"logo":{"light":"https://mintcdn.com/multiwoven-74/-MbwV9-QpicPIrse/logo/ai-squared-docs-logo-light.svg?fit=max\u0026auto=format\u0026n=-MbwV9-QpicPIrse\u0026q=85\u0026s=ca08017182cbe96397a10feab3cfeda6","dark":"https://mintcdn.com/multiwoven-74/-MbwV9-QpicPIrse/logo/ai-squared-docs-logo-dark.svg?fit=max\u0026auto=format\u0026n=-MbwV9-QpicPIrse\u0026q=85\u0026s=c68b55937e803881c30f296d78422e53"},"favicon":"https://mintcdn.com/multiwoven-74/-MbwV9-QpicPIrse/favicon.svg?fit=max\u0026auto=format\u0026n=-MbwV9-QpicPIrse\u0026q=85\u0026s=d664c5e29af113255a0beffa1adc634c","navbar":{"links":[{"href":"https://squared.ai","label":"Book a Demo"}],"primary":{"type":"button","label":"Back to App","href":"https://app.squared.ai"}},"footer":{"socials":{"github":"https://github.com/Multiwoven/multiwoven","linkedin":"https://www.linkedin.com/company/aisquaredinc"}},"styling":{"latex":false},"integrations":{"mixpanel":{"projectToken":"cd589b1602a01416f4cc17aa04accc66"}},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"multiwoven-74","hasAudioNarration":false,"actualSubdomain":"multiwoven-74","customDomains":["docs.squared.ai"],"gitSource":{"type":"github","owner":"multiwoven","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae83b1f6e6e556c3ab68690","collectionId":"00447bbb-3cbd-4642-b21e-5238f8861193","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae83b1f6e6e556c3ab68690"},"feedback":{"thumbs":true,"edits":false,"issues":false},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"DISABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"DISABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae83b1f6e6e556c3ab68690","clientVersion":"0.0.4054","searchFilterCounts":[{"language":"default","tag":"Data Movement","count":65},{"language":"default","tag":"Product Updates","count":62},{"language":"default","tag":"Destinations","count":37},{"language":"default","tag":"Business Applications","count":37},{"language":"default","tag":"Developers","count":30},{"language":"default","tag":"AI Activation","count":24},{"language":"default","tag":"Deployment \u0026 Security","count":22},{"language":"default","tag":"Sources","count":20},{"language":"default","tag":"Data Sources","count":19},{"language":"default","tag":"Deployment","count":17}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"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":"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":"byok-sep-25","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":"billing-updated-9-15","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":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":".border-primary{--tw-border-opacity:1;border-color:rgb(var(--primary)/var(--tw-border-opacity));margin-bottom:2px;border-bottom-width:.1875rem}#topbar-cta-button a{display:flex;align-items:center;padding:.475rem 1rem!important;gap:.5rem;color:#fff!important;border-radius:.25rem;font-weight:500;letter-spacing:.4px}"}],"page":{"pagePath":"guides/data-modelling/models/sql","slug":"/guides/data-modelling/models/sql","pageMetadata":{"title":"SQL Editor","description":"SQL Editor for Data Modeling in AI Squared","href":"/guides/data-modelling/models/sql"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"SQL Editor for Data Modeling in AI Squared\"\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`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`overview`,children:`Overview`}),`\n`,_jsx(_components.p,{children:`AI Squared’s SQL Editor allows you to define and manage your data models directly through SQL queries. This powerful tool supports native SQL commands compatible with your data warehouse, enabling you to seamlessly model your data.`}),`\n`,_jsx(Heading,{level:`2`,id:`creating-a-model-with-the-sql-editor`,children:`Creating a Model with the SQL Editor`}),`\n`,_jsx(Heading,{level:`3`,id:`starting-with-a-query`,children:`Starting with a Query`}),`\n`,_jsx(_components.p,{children:`Begin by writing a SQL query to define your model. For instance, if using a typical eCommerce dataset, you might start with a query like:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,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:`1`,children:[_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:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` sales_data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`customers`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`previewing-your-data`,children:`Previewing Your Data`}),`\n`,_jsxs(_components.p,{children:[`Click the `,_jsx(_components.code,{children:`Preview`}),` button to review the first 100 rows of your data. This step ensures the query fetches the expected data. After verifying, proceed by clicking `,_jsx(_components.code,{children:`Continue`}),`.`]}),`\n`,_jsxs(Tip,{children:[_jsx(_components.strong,{children:`Important Note:`}),` The model cannot be saved if the query is incorrect or yields no results.`]}),`\n`,_jsx(Heading,{level:`3`,id:`configuring-model-details`,children:`Configuring Model Details`}),`\n`,_jsx(_components.p,{children:`Finalize your model by:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Naming the model descriptively.`}),`\n`,_jsx(_components.li,{children:`Choosing a column as the Primary Key.`}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`completing-the-setup`,children:`Completing the Setup`}),`\n`,_jsxs(_components.p,{children:[`Finish your model setup by clicking the `,_jsx(_components.code,{children:`Finish`}),` button.`]}),`\n`,_jsx(Heading,{level:`2`,id:`unique-primary-key-requirement`,children:`Unique Primary Key Requirement`}),`\n`,_jsx(_components.p,{children:`Every model requires a unique primary key. If no unique column exists, consider:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Removing duplicate rows.`}),`\n`,_jsx(_components.li,{children:`Creating a composite column for the primary key.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`handling-duplicate-data`,children:`Handling Duplicate Data`}),`\n`,_jsxs(_components.p,{children:[`To filter duplicates, use a `,_jsx(_components.code,{children:`GROUP BY`}),` clause in your SQL query. For instance:`]}),`\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:`SELECT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`})]}),`\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:` customer_data`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`GROUP BY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` unique_identifier_column`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`composite-primary-keys`,children:`Composite Primary Keys`}),`\n`,_jsx(_components.p,{children:`In scenarios where a unique primary key is not available, construct a composite key. Example:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,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:`5`,children:[_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:` customer_id, `})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` email, `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` purchase_date,`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MD5(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`CONCAT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(customer_id, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'-'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, email)) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` composite_key`})]}),`\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:` sales_data`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`saving-a-model-without-current-results`,children:`Saving a Model Without Current Results`}),`\n`,_jsx(_components.p,{children:`To save a model expected to have future data:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,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:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`UNION ALL`})}),`\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\":`#569CD6`},children:` NULL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`NULL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`NULL`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Add this to your query to include a dummy row, ensuring the model can be saved.`}),`\n`,_jsx(Heading,{level:`2`,id:`excluding-rows-with-null-values`,children:`Excluding Rows with Null Values`}),`\n`,_jsx(_components.p,{children:`To exclude rows with null values:`}),`\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:`SELECT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`})]}),`\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:` your_dataset`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`WHERE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` important_column1 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`IS NOT NULL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` AND`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` important_column2 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`IS NOT NULL`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Replace `,_jsx(_components.code,{children:`important_column1`}),`, `,_jsx(_components.code,{children:`important_column2`}),`, etc., with your relevant column names.`]})]})}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":"SQL Editor","description":"SQL Editor for Data Modeling in AI Squared","href":"/guides/data-modelling/models/sql"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Overview","slug":"overview","depth":2,"children":[]},{"title":"Creating a Model with the SQL Editor","slug":"creating-a-model-with-the-sql-editor","depth":2,"children":[{"title":"Starting with a Query","slug":"starting-with-a-query","depth":3,"children":[]},{"title":"Previewing Your Data","slug":"previewing-your-data","depth":3,"children":[]},{"title":"Configuring Model Details","slug":"configuring-model-details","depth":3,"children":[]},{"title":"Completing the Setup","slug":"completing-the-setup","depth":3,"children":[]}]},{"title":"Unique Primary Key Requirement","slug":"unique-primary-key-requirement","depth":2,"children":[]},{"title":"Handling Duplicate Data","slug":"handling-duplicate-data","depth":2,"children":[]},{"title":"Composite Primary Keys","slug":"composite-primary-keys","depth":2,"children":[]},{"title":"Saving a Model Without Current Results","slug":"saving-a-model-without-current-results","depth":2,"children":[]},{"title":"Excluding Rows with Null Values","slug":"excluding-rows-with-null-values","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/multiwoven-74/aaa40dfb088f7973/docs-bot.js"],"subdomain":"multiwoven-74","siteName":"AI Squared","title":"SQL Editor - AI Squared","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2025-10-08T09:27:36.322Z","originalFileLocation":"guides/data-modelling/models/sql.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=\"SQL Editor for Data Modeling in AI Squared\">\u003cmeta data-mint-head name=\"application-name\" content=\"AI Squared\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/multiwoven-74/NkrXgVYPR_dCevS6/_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/multiwoven-74/NkrXgVYPR_dCevS6/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/multiwoven-74/NkrXgVYPR_dCevS6/_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/multiwoven-74/NkrXgVYPR_dCevS6/_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/multiwoven-74/NkrXgVYPR_dCevS6/_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/multiwoven-74/NkrXgVYPR_dCevS6/_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/multiwoven-74/NkrXgVYPR_dCevS6/_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/multiwoven-74/NkrXgVYPR_dCevS6/_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/multiwoven-74/NkrXgVYPR_dCevS6/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"SQL Editor - AI Squared\">\u003cmeta data-mint-head property=\"og:description\" content=\"SQL Editor for Data Modeling in AI Squared\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"AI Squared\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.squared.ai/guides/data-modelling/models/sql\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://multiwoven-74.mintlify.app/_mintlify/api/og/v2?division=Data+Modelling\u0026amp;title=SQL+Editor\u0026amp;description=SQL+Editor+for+Data+Modeling+in+AI+Squared\u0026amp;theme=f527afd5024577da42908e7f\u0026amp;signature=9283e41ca48e9d6c71a422e25df2c4d1997fc6213ef91c9b01c1bff4ae61792b\">\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=\"SQL Editor - AI Squared\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"SQL Editor for Data Modeling in AI Squared\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://multiwoven-74.mintlify.app/_mintlify/api/og/v2?division=Data+Modelling\u0026amp;title=SQL+Editor\u0026amp;description=SQL+Editor+for+Data+Modeling+in+AI+Squared\u0026amp;theme=f527afd5024577da42908e7f\u0026amp;signature=9283e41ca48e9d6c71a422e25df2c4d1997fc6213ef91c9b01c1bff4ae61792b\">\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/multiwoven-74/NkrXgVYPR_dCevS6/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"AI Squared\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#00249c\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.squared.ai/guides/data-modelling/models/sql\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guides/data-modelling/models/sql.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.squared.ai/#organization\",\"name\":\"AI Squared\",\"url\":\"https://docs.squared.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/multiwoven-74/-MbwV9-QpicPIrse/logo/ai-squared-docs-logo-light.svg?fit=max\u0026auto=format\u0026n=-MbwV9-QpicPIrse\u0026q=85\u0026s=ca08017182cbe96397a10feab3cfeda6\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.squared.ai#website\",\"name\":\"AI Squared\",\"url\":\"https://docs.squared.ai\",\"publisher\":{\"@id\":\"https://docs.squared.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.squared.ai/guides/data-modelling/models/sql#webpage\",\"url\":\"https://docs.squared.ai/guides/data-modelling/models/sql\",\"name\":\"SQL Editor\",\"description\":\"SQL Editor for Data Modeling in AI Squared\",\"dateModified\":\"2025-10-08T09:27:36.322Z\",\"isPartOf\":{\"@id\":\"https://docs.squared.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.squared.ai/guides/data-modelling/models/sql#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.squared.ai/guides/data-modelling/models/sql#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Data Modelling\",\"item\":\"https://docs.squared.ai/guides/data-modelling/models/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Editor\",\"item\":\"https://docs.squared.ai/guides/data-modelling/models/sql\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.squared.ai/guides/data-modelling/models/sql#article\",\"headline\":\"SQL Editor\",\"name\":\"SQL Editor\",\"description\":\"SQL Editor for Data Modeling in AI Squared\",\"url\":\"https://docs.squared.ai/guides/data-modelling/models/sql\",\"mainEntityOfPage\":{\"@id\":\"https://docs.squared.ai/guides/data-modelling/models/sql#webpage\"},\"dateModified\":\"2025-10-08T09:27:36.322Z\",\"publisher\":{\"@id\":\"https://docs.squared.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.squared.ai#website\"}}]}\u003c/script>","siteName":"AI Squared","nav":{"global":null,"tabs":[{"tab":"Home","pages":[{"title":"Home","href":"/home/welcome"}]},{"tab":"Getting Started","pages":[{"title":"Getting Started","href":"/getting-started/introduction"}]},{"tab":"AI Activation","pages":[{"title":"AI Activation","href":"/activation/ai-modelling/introduction"}]},{"tab":"AI Workflows","pages":[{"title":"AI Workflows","href":"/workflows/overview"}]},{"tab":"Data Movement","groups":[{"group":"Overview","pages":[{"title":"Introduction","icon":"","href":"/guides/core-concepts"}]},{"group":"Sources","pages":[{"title":"Adding a Data Source","href":"/guides/add-data-source"},{"group":"Data Sources","pages":[{"title":"Amazon Redshift","href":"/guides/sources/data-sources/redshift"},{"title":"Snowflake","href":"/guides/sources/data-sources/snowflake"},{"title":"Google Big Query","href":"/guides/sources/data-sources/bquery"},{"title":"Databricks","href":"/guides/sources/data-sources/databricks"},{"title":"PostgreSQL","href":"/guides/sources/data-sources/postgresql"},{"title":"Salesforce Consumer Goods Cloud","href":"/guides/sources/data-sources/salesforce-consumer-goods-cloud"},{"title":"AWS Athena","href":"/guides/sources/data-sources/aws_athena"},{"title":"ClickHouse","href":"/guides/sources/data-sources/clickhouse"},{"title":"MariaDB","href":"/guides/sources/data-sources/maria_db"},{"title":"Oracle","href":"/guides/sources/data-sources/oracle"},{"title":"S3","href":"/guides/sources/data-sources/amazon_s3"},{"title":"Databricks Model","href":"/guides/sources/data-sources/databricks-model"},{"title":"AWS Sagemaker Model","href":"/guides/sources/data-sources/aws_sagemaker-model"},{"title":"SFTP","href":"/guides/sources/data-sources/sftp"},{"title":"WatsonX.Data","href":"/guides/sources/data-sources/watsonx_data"},{"title":"Intuit QuickBooks","href":"/guides/sources/data-sources/intuit_quickbooks"},{"title":"Firecrawl","href":"/guides/sources/data-sources/firecrawl"},{"title":"Odoo","href":"/guides/sources/data-sources/odoo"},{"title":"Google Drive","href":"/guides/sources/data-sources/google-drive"}]}]},{"group":"Destinations","pages":[{"group":"Business Applications","pages":[{"title":"Salesforce","href":"/guides/destinations/retl-destinations/crm/salesforce"},{"title":"HubSpot","href":"/guides/destinations/retl-destinations/crm/hubspot"},{"title":"Zoho","href":"/guides/destinations/retl-destinations/crm/zoho"},{"title":"Microsoft Dynamics","href":"/guides/destinations/retl-destinations/crm/microsoft_dynamics"},{"title":"Braze","href":"/guides/destinations/retl-destinations/marketing-automation/braze"},{"title":"CleverTap","href":"/guides/destinations/retl-destinations/marketing-automation/clevertap"},{"title":"Klaviyo","href":"/guides/destinations/retl-destinations/marketing-automation/klaviyo"},{"title":"Iterable","href":"/guides/destinations/retl-destinations/marketing-automation/iterable"},{"title":null,"href":"/guides/destinations/retl-destinations/marketing-automation/mailchimp"},{"title":"Facebook Custom Audiences","href":"/guides/destinations/retl-destinations/adtech/facebook-ads"},{"title":"Google Ads","href":"/guides/destinations/retl-destinations/adtech/google-ads"},{"title":"Google Analytics","href":"/guides/destinations/retl-destinations/analytics/google-analytics"},{"title":"Mixpanel","href":"/guides/destinations/retl-destinations/analytics/mixpanel"},{"title":"Amplitude","href":"/guides/destinations/retl-destinations/analytics/amplitude"},{"title":"Databricks","href":"/guides/destinations/retl-destinations/analytics/databricks_lakehouse"},{"title":"Zendesk","icon":"zendesk","href":"/guides/destinations/retl-destinations/customer-support/zendesk"},{"title":null,"href":"/guides/destinations/retl-destinations/customer-support/intercom"},{"title":"Slack","href":"/guides/destinations/retl-destinations/team-collaboration/slack"},{"title":null,"href":"/guides/destinations/retl-destinations/team-collaboration/microsoft-teams"},{"title":null,"href":"/guides/destinations/retl-destinations/e-commerce/shopify"},{"title":null,"href":"/guides/destinations/retl-destinations/e-commerce/facebook-product-catalog"},{"title":"Stripe","href":"/guides/destinations/retl-destinations/payment/stripe"},{"title":"Salesforce Consumer Goods Cloud","href":"/guides/destinations/retl-destinations/retail/salesforce-consumer-goods-cloud"},{"title":"Airtable","href":"/guides/destinations/retl-destinations/productivity-tools/airtable"},{"title":"Google Sheets - Service Account","href":"/guides/destinations/retl-destinations/productivity-tools/google-sheets"},{"title":"Microsoft Excel","href":"/guides/destinations/retl-destinations/productivity-tools/microsoft-excel"},{"title":"SFTP","href":"/guides/destinations/retl-destinations/file-storage/sftp"},{"title":"PostgreSQL","href":"/guides/destinations/retl-destinations/database/postgresql"},{"title":"MariaDB","href":"/guides/destinations/retl-destinations/database/maria_db"},{"title":"Oracle","href":"/guides/destinations/retl-destinations/database/oracle"},{"title":"Pinecone DB","href":"/guides/destinations/retl-destinations/database/pinecone_db"},{"title":"Qdrant","href":"/guides/destinations/retl-destinations/database/qdrant"},{"title":"Weaviate","href":"/guides/destinations/retl-destinations/database/weaviate"},{"title":"HTTP","href":"/guides/destinations/retl-destinations/http/http"},{"title":"MicrosoftSQL","href":"/guides/destinations/retl-destinations/database/ms_sql"},{"title":"Amazon S3","href":"/guides/destinations/retl-destinations/file-storage/amazon_s3"},{"title":"Odoo","href":"/guides/destinations/retl-destinations/crm/odoo"},{"title":"Weaviate","href":"/guides/destinations/retl-destinations/database/weaviate"}]}]},{"group":"Data Modelling","pages":[{"title":"Overview","description":null,"href":"/guides/data-modelling/models/overview"},{"title":"SQL Editor","href":"/guides/data-modelling/models/sql"},{"title":"Table Selector","description":null,"href":"/guides/data-modelling/models/table-visualization"}]},{"group":"Data Syncs","pages":[{"title":"Overview","href":"/guides/data-modelling/syncs/overview"},{"title":"Full Refresh","href":"/guides/data-modelling/sync-modes/full-refresh"},{"title":"Incremental","href":"/guides/data-modelling/sync-modes/incremental"},{"title":"Incremental - Cursor Field","href":"/guides/data-modelling/sync-modes/cursor-incremental"}]}]},{"tab":"Sparx","pages":[{"title":"Sparx","href":"/sparx/overview"}]},{"tab":"Proprietary Models","pages":[{"title":"Proprietary Models","href":"/overview"}]},{"tab":"Deployment \u0026 Security","pages":[{"title":"Deployment \u0026 Security","href":"/deployment-and-security/overview"}]},{"tab":"Developers","pages":[{"title":"Developers","href":"/api-reference/introduction"}]},{"tab":"Product Updates","pages":[{"title":"Product Updates","href":"/release-notes/2026"}]}]},"basePath":"","title":"SQL Editor - AI Squared","buildId":"dpl_345ReqzYaAjzS9QpeJemsKdb7KDj","deploymentId":"dpl_345ReqzYaAjzS9QpeJemsKdb7KDj","dynamics":[],"chunks":[]}