[{"data":1,"prerenderedAt":782},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fanalysis\u002Fsql-editor":3},{"page":4,"navigation":699,"surround":779},{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"body":11,"_type":693,"_id":694,"_source":695,"_file":696,"_stem":697,"_extension":698},"\u002Fdocs\u002Fanalysis\u002Fsql-editor","analysis",false,"","SQL editor","Write SQL against every synced table and model, using DuckDB's dialect, and know the limits.",{"type":12,"children":13,"toc":686},"root",[14,30,37,115,121,136,409,415,522,534,540,545,608,614,675,680],{"type":15,"tag":16,"props":17,"children":18},"element","p",{},[19,22,28],{"type":20,"value":21},"text","The ",{"type":15,"tag":23,"props":24,"children":25},"strong",{},[26],{"type":20,"value":27},"SQL",{"type":20,"value":29}," page is a full SQL editor over everything in your workspace. Your source systems' reporting limits don't apply: you can join across systems, use window functions, and query years of history.",{"type":15,"tag":31,"props":32,"children":34},"h2",{"id":33},"the-editor",[35],{"type":20,"value":36},"The editor",{"type":15,"tag":38,"props":39,"children":40},"ul",{},[41,52,62,73,83,102],{"type":15,"tag":42,"props":43,"children":44},"li",{},[45,50],{"type":15,"tag":23,"props":46,"children":47},{},[48],{"type":20,"value":49},"Autocomplete",{"type":20,"value":51}," covers every synced table, column and model in the workspace.",{"type":15,"tag":42,"props":53,"children":54},{},[55,60],{"type":15,"tag":23,"props":56,"children":57},{},[58],{"type":20,"value":59},"Run",{"type":20,"value":61}," with ⌘↵ (Ctrl+Enter on Windows).",{"type":15,"tag":42,"props":63,"children":64},{},[65,66,71],{"type":20,"value":21},{"type":15,"tag":23,"props":67,"children":68},{},[69],{"type":20,"value":70},"Tables",{"type":20,"value":72}," panel lists your tables, grouped by connection.",{"type":15,"tag":42,"props":74,"children":75},{},[76,81],{"type":15,"tag":23,"props":77,"children":78},{},[79],{"type":20,"value":80},"Explain",{"type":20,"value":82}," describes what the selected SQL does, in a few sentences.",{"type":15,"tag":42,"props":84,"children":85},{},[86,91,93,100],{"type":15,"tag":23,"props":87,"children":88},{},[89],{"type":20,"value":90},"Save as model",{"type":20,"value":92}," turns the query into a ",{"type":15,"tag":94,"props":95,"children":97},"a",{"href":96},"\u002Fdocs\u002Fmodels\u002Foverview",[98],{"type":20,"value":99},"model",{"type":20,"value":101},".",{"type":15,"tag":42,"props":103,"children":104},{},[105,107,113],{"type":20,"value":106},"Work is kept in named ",{"type":15,"tag":94,"props":108,"children":110},{"href":109},"\u002Fdocs\u002Fanalysis\u002Ftabs-and-sharing",[111],{"type":20,"value":112},"tabs",{"type":20,"value":114}," that are saved on the server.",{"type":15,"tag":31,"props":116,"children":118},{"id":117},"dialect",[119],{"type":20,"value":120},"Dialect",{"type":15,"tag":16,"props":122,"children":123},{},[124,126,134],{"type":20,"value":125},"Datachef runs ",{"type":15,"tag":94,"props":127,"children":131},{"href":128,"rel":129},"https:\u002F\u002Fduckdb.org\u002Fdocs\u002Fsql\u002Fintroduction",[130],"nofollow",[132],{"type":20,"value":133},"DuckDB",{"type":20,"value":135},"'s SQL dialect. It's close to PostgreSQL, with useful extras:",{"type":15,"tag":137,"props":138,"children":142},"pre",{"className":139,"code":140,"language":141,"meta":8,"style":8},"language-sql shiki shiki-themes github-light github-dark","-- Group by every non-aggregated column\nSELECT region, plan, sum(mrr) FROM sample.customers GROUP BY ALL;\n\n-- Filter on a window function without a subquery\nSELECT * FROM salesforce.opportunity\nQUALIFY row_number() OVER (PARTITION BY accountid ORDER BY closedate DESC) = 1;\n\n-- Exclude a column from SELECT *\nSELECT * EXCLUDE (description) FROM salesforce.account;\n","sql",[143],{"type":15,"tag":144,"props":145,"children":146},"code",{"__ignoreMap":8},[147,159,215,225,234,266,345,353,362],{"type":15,"tag":148,"props":149,"children":152},"span",{"class":150,"line":151},"line",1,[153],{"type":15,"tag":148,"props":154,"children":156},{"style":155},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[157],{"type":20,"value":158},"-- Group by every non-aggregated column\n",{"type":15,"tag":148,"props":160,"children":162},{"class":150,"line":161},2,[163,169,175,181,186,191,196,200,205,210],{"type":15,"tag":148,"props":164,"children":166},{"style":165},"--shiki-default:#D73A49;--shiki-dark:#F97583",[167],{"type":20,"value":168},"SELECT",{"type":15,"tag":148,"props":170,"children":172},{"style":171},"--shiki-default:#24292E;--shiki-dark:#E1E4E8",[173],{"type":20,"value":174}," region, plan, ",{"type":15,"tag":148,"props":176,"children":178},{"style":177},"--shiki-default:#005CC5;--shiki-dark:#79B8FF",[179],{"type":20,"value":180},"sum",{"type":15,"tag":148,"props":182,"children":183},{"style":171},[184],{"type":20,"value":185},"(mrr) ",{"type":15,"tag":148,"props":187,"children":188},{"style":165},[189],{"type":20,"value":190},"FROM",{"type":15,"tag":148,"props":192,"children":193},{"style":177},[194],{"type":20,"value":195}," sample",{"type":15,"tag":148,"props":197,"children":198},{"style":171},[199],{"type":20,"value":101},{"type":15,"tag":148,"props":201,"children":202},{"style":177},[203],{"type":20,"value":204},"customers",{"type":15,"tag":148,"props":206,"children":207},{"style":165},[208],{"type":20,"value":209}," GROUP BY",{"type":15,"tag":148,"props":211,"children":212},{"style":171},[213],{"type":20,"value":214}," ALL;\n",{"type":15,"tag":148,"props":216,"children":218},{"class":150,"line":217},3,[219],{"type":15,"tag":148,"props":220,"children":222},{"emptyLinePlaceholder":221},true,[223],{"type":20,"value":224},"\n",{"type":15,"tag":148,"props":226,"children":228},{"class":150,"line":227},4,[229],{"type":15,"tag":148,"props":230,"children":231},{"style":155},[232],{"type":20,"value":233},"-- Filter on a window function without a subquery\n",{"type":15,"tag":148,"props":235,"children":237},{"class":150,"line":236},5,[238,242,247,252,257,261],{"type":15,"tag":148,"props":239,"children":240},{"style":165},[241],{"type":20,"value":168},{"type":15,"tag":148,"props":243,"children":244},{"style":165},[245],{"type":20,"value":246}," *",{"type":15,"tag":148,"props":248,"children":249},{"style":165},[250],{"type":20,"value":251}," FROM",{"type":15,"tag":148,"props":253,"children":254},{"style":177},[255],{"type":20,"value":256}," salesforce",{"type":15,"tag":148,"props":258,"children":259},{"style":171},[260],{"type":20,"value":101},{"type":15,"tag":148,"props":262,"children":263},{"style":177},[264],{"type":20,"value":265},"opportunity\n",{"type":15,"tag":148,"props":267,"children":269},{"class":150,"line":268},6,[270,275,280,285,290,295,300,305,310,315,320,325,330,335,340],{"type":15,"tag":148,"props":271,"children":272},{"style":171},[273],{"type":20,"value":274},"QUALIFY ",{"type":15,"tag":148,"props":276,"children":277},{"style":177},[278],{"type":20,"value":279},"row_number",{"type":15,"tag":148,"props":281,"children":282},{"style":171},[283],{"type":20,"value":284},"() ",{"type":15,"tag":148,"props":286,"children":287},{"style":165},[288],{"type":20,"value":289},"OVER",{"type":15,"tag":148,"props":291,"children":292},{"style":171},[293],{"type":20,"value":294}," (",{"type":15,"tag":148,"props":296,"children":297},{"style":165},[298],{"type":20,"value":299},"PARTITION",{"type":15,"tag":148,"props":301,"children":302},{"style":165},[303],{"type":20,"value":304}," BY",{"type":15,"tag":148,"props":306,"children":307},{"style":171},[308],{"type":20,"value":309}," accountid ",{"type":15,"tag":148,"props":311,"children":312},{"style":165},[313],{"type":20,"value":314},"ORDER BY",{"type":15,"tag":148,"props":316,"children":317},{"style":171},[318],{"type":20,"value":319}," closedate ",{"type":15,"tag":148,"props":321,"children":322},{"style":165},[323],{"type":20,"value":324},"DESC",{"type":15,"tag":148,"props":326,"children":327},{"style":171},[328],{"type":20,"value":329},") ",{"type":15,"tag":148,"props":331,"children":332},{"style":165},[333],{"type":20,"value":334},"=",{"type":15,"tag":148,"props":336,"children":337},{"style":177},[338],{"type":20,"value":339}," 1",{"type":15,"tag":148,"props":341,"children":342},{"style":171},[343],{"type":20,"value":344},";\n",{"type":15,"tag":148,"props":346,"children":348},{"class":150,"line":347},7,[349],{"type":15,"tag":148,"props":350,"children":351},{"emptyLinePlaceholder":221},[352],{"type":20,"value":224},{"type":15,"tag":148,"props":354,"children":356},{"class":150,"line":355},8,[357],{"type":15,"tag":148,"props":358,"children":359},{"style":155},[360],{"type":20,"value":361},"-- Exclude a column from SELECT *\n",{"type":15,"tag":148,"props":363,"children":365},{"class":150,"line":364},9,[366,370,374,379,384,388,392,396,400,405],{"type":15,"tag":148,"props":367,"children":368},{"style":165},[369],{"type":20,"value":168},{"type":15,"tag":148,"props":371,"children":372},{"style":165},[373],{"type":20,"value":246},{"type":15,"tag":148,"props":375,"children":376},{"style":171},[377],{"type":20,"value":378}," EXCLUDE (",{"type":15,"tag":148,"props":380,"children":381},{"style":165},[382],{"type":20,"value":383},"description",{"type":15,"tag":148,"props":385,"children":386},{"style":171},[387],{"type":20,"value":329},{"type":15,"tag":148,"props":389,"children":390},{"style":165},[391],{"type":20,"value":190},{"type":15,"tag":148,"props":393,"children":394},{"style":177},[395],{"type":20,"value":256},{"type":15,"tag":148,"props":397,"children":398},{"style":171},[399],{"type":20,"value":101},{"type":15,"tag":148,"props":401,"children":402},{"style":177},[403],{"type":20,"value":404},"account",{"type":15,"tag":148,"props":406,"children":407},{"style":171},[408],{"type":20,"value":344},{"type":15,"tag":31,"props":410,"children":412},{"id":411},"naming-tables-and-models",[413],{"type":20,"value":414},"Naming tables and models",{"type":15,"tag":416,"props":417,"children":418},"table",{},[419,443],{"type":15,"tag":420,"props":421,"children":422},"thead",{},[423],{"type":15,"tag":424,"props":425,"children":426},"tr",{},[427,433,438],{"type":15,"tag":428,"props":429,"children":430},"th",{},[431],{"type":20,"value":432},"What",{"type":15,"tag":428,"props":434,"children":435},{},[436],{"type":20,"value":437},"How to refer to it",{"type":15,"tag":428,"props":439,"children":440},{},[441],{"type":20,"value":442},"Example",{"type":15,"tag":444,"props":445,"children":446},"tbody",{},[447,474,500],{"type":15,"tag":424,"props":448,"children":449},{},[450,456,465],{"type":15,"tag":451,"props":452,"children":453},"td",{},[454],{"type":20,"value":455},"A synced table",{"type":15,"tag":451,"props":457,"children":458},{},[459],{"type":15,"tag":144,"props":460,"children":462},{"className":461},[],[463],{"type":20,"value":464},"\u003Cconnection name>.\u003Ctable>",{"type":15,"tag":451,"props":466,"children":467},{},[468],{"type":15,"tag":144,"props":469,"children":471},{"className":470},[],[472],{"type":20,"value":473},"salesforce.opportunity",{"type":15,"tag":424,"props":475,"children":476},{},[477,482,491],{"type":15,"tag":451,"props":478,"children":479},{},[480],{"type":20,"value":481},"A database table outside the default schema",{"type":15,"tag":451,"props":483,"children":484},{},[485],{"type":15,"tag":144,"props":486,"children":488},{"className":487},[],[489],{"type":20,"value":490},"\u003Cconnection name>.\u003Cschema>_\u003Ctable>",{"type":15,"tag":451,"props":492,"children":493},{},[494],{"type":15,"tag":144,"props":495,"children":497},{"className":496},[],[498],{"type":20,"value":499},"warehouse.sales_orders",{"type":15,"tag":424,"props":501,"children":502},{},[503,508,513],{"type":15,"tag":451,"props":504,"children":505},{},[506],{"type":20,"value":507},"A model",{"type":15,"tag":451,"props":509,"children":510},{},[511],{"type":20,"value":512},"Its name",{"type":15,"tag":451,"props":514,"children":515},{},[516],{"type":15,"tag":144,"props":517,"children":519},{"className":518},[],[520],{"type":20,"value":521},"active_customers",{"type":15,"tag":16,"props":523,"children":524},{},[525,527,533],{"type":20,"value":526},"See ",{"type":15,"tag":94,"props":528,"children":530},{"href":529},"\u002Fdocs\u002Fconnections\u002Foverview#connection-names-and-labels",[531],{"type":20,"value":532},"connection names",{"type":20,"value":101},{"type":15,"tag":31,"props":535,"children":537},{"id":536},"read-only",[538],{"type":20,"value":539},"Read-only",{"type":15,"tag":16,"props":541,"children":542},{},[543],{"type":20,"value":544},"Every query is read-only:",{"type":15,"tag":38,"props":546,"children":547},{},[548,568,603],{"type":15,"tag":42,"props":549,"children":550},{},[551,553,558,560,566],{"type":20,"value":552},"One statement per query, and it must be a ",{"type":15,"tag":144,"props":554,"children":556},{"className":555},[],[557],{"type":20,"value":168},{"type":20,"value":559}," (including ",{"type":15,"tag":144,"props":561,"children":563},{"className":562},[],[564],{"type":20,"value":565},"WITH ... SELECT",{"type":20,"value":567},").",{"type":15,"tag":42,"props":569,"children":570},{},[571,573,579,581,587,588,594,595,601],{"type":20,"value":572},"Statements that write data or reach outside the workspace are refused. That includes ",{"type":15,"tag":144,"props":574,"children":576},{"className":575},[],[577],{"type":20,"value":578},"ATTACH",{"type":20,"value":580},", ",{"type":15,"tag":144,"props":582,"children":584},{"className":583},[],[585],{"type":20,"value":586},"COPY",{"type":20,"value":580},{"type":15,"tag":144,"props":589,"children":591},{"className":590},[],[592],{"type":20,"value":593},"INSTALL",{"type":20,"value":580},{"type":15,"tag":144,"props":596,"children":598},{"className":597},[],[599],{"type":20,"value":600},"PRAGMA",{"type":20,"value":602},", and functions that read files or URLs.",{"type":15,"tag":42,"props":604,"children":605},{},[606],{"type":20,"value":607},"A query can only see tables and models in its own workspace.",{"type":15,"tag":31,"props":609,"children":611},{"id":610},"limits",[612],{"type":20,"value":613},"Limits",{"type":15,"tag":416,"props":615,"children":616},{},[617,633],{"type":15,"tag":420,"props":618,"children":619},{},[620],{"type":15,"tag":424,"props":621,"children":622},{},[623,628],{"type":15,"tag":428,"props":624,"children":625},{},[626],{"type":20,"value":627},"Limit",{"type":15,"tag":428,"props":629,"children":630},{},[631],{"type":20,"value":632},"Value",{"type":15,"tag":444,"props":634,"children":635},{},[636,649,662],{"type":15,"tag":424,"props":637,"children":638},{},[639,644],{"type":15,"tag":451,"props":640,"children":641},{},[642],{"type":20,"value":643},"Rows shown in a result",{"type":15,"tag":451,"props":645,"children":646},{},[647],{"type":20,"value":648},"10,000. A larger result is marked as truncated.",{"type":15,"tag":424,"props":650,"children":651},{},[652,657],{"type":15,"tag":451,"props":653,"children":654},{},[655],{"type":20,"value":656},"Rows in a CSV export",{"type":15,"tag":451,"props":658,"children":659},{},[660],{"type":20,"value":661},"1,000,000",{"type":15,"tag":424,"props":663,"children":664},{},[665,670],{"type":15,"tag":451,"props":666,"children":667},{},[668],{"type":20,"value":669},"Query time",{"type":15,"tag":451,"props":671,"children":672},{},[673],{"type":20,"value":674},"60 seconds",{"type":15,"tag":16,"props":676,"children":677},{},[678],{"type":20,"value":679},"If you hit the row limit, aggregate in SQL instead. Summing or counting in the query is faster than pulling the rows out.",{"type":15,"tag":681,"props":682,"children":683},"style",{},[684],{"type":20,"value":685},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":8,"searchDepth":161,"depth":161,"links":687},[688,689,690,691,692],{"id":33,"depth":161,"text":36},{"id":117,"depth":161,"text":120},{"id":411,"depth":161,"text":414},{"id":536,"depth":161,"text":539},{"id":610,"depth":161,"text":613},"markdown","content:docs:3.analysis:2.sql-editor.md","content","docs\u002F3.analysis\u002F2.sql-editor.md","docs\u002F3.analysis\u002F2.sql-editor","md",[700],{"title":701,"_path":702,"children":703},"Welcome","\u002Fdocs",[704,705,715,737,750,756,766],{"title":701,"_path":702},{"title":706,"_path":707,"children":708},"Getting started","\u002Fdocs\u002Fgetting-started",[709,712],{"title":710,"_path":711},"Quickstart","\u002Fdocs\u002Fgetting-started\u002Fquickstart",{"title":713,"_path":714},"Key concepts","\u002Fdocs\u002Fgetting-started\u002Fconcepts",{"title":716,"_path":717,"children":718},"Connecting data","\u002Fdocs\u002Fconnections",[719,722,725,728,731,734],{"title":720,"_path":721},"Overview","\u002Fdocs\u002Fconnections\u002Foverview",{"title":723,"_path":724},"Sync settings","\u002Fdocs\u002Fconnections\u002Fsync-settings",{"title":726,"_path":727},"Salesforce","\u002Fdocs\u002Fconnections\u002Fsalesforce",{"title":729,"_path":730},"Marketo","\u002Fdocs\u002Fconnections\u002Fmarketo",{"title":732,"_path":733},"Google Analytics 4","\u002Fdocs\u002Fconnections\u002Fgoogle-analytics-4",{"title":735,"_path":736},"PostgreSQL and MySQL","\u002Fdocs\u002Fconnections\u002Fpostgres-mysql",{"title":738,"_path":739,"children":740},"Analysis","\u002Fdocs\u002Fanalysis",[741,744,745,748],{"title":742,"_path":743},"Asking questions","\u002Fdocs\u002Fanalysis\u002Fask-a-question",{"title":9,"_path":5},{"title":746,"_path":747},"Charts","\u002Fdocs\u002Fanalysis\u002Fcharts",{"title":749,"_path":109},"Tabs and sharing",{"title":751,"_path":752,"children":753},"Models","\u002Fdocs\u002Fmodels",[754],{"title":755,"_path":96},"Working with models",{"title":757,"_path":758,"children":759},"AI agents","\u002Fdocs\u002Fai-agents",[760,763],{"title":761,"_path":762},"Claude connector","\u002Fdocs\u002Fai-agents\u002Fclaude-connector",{"title":764,"_path":765},"Tools","\u002Fdocs\u002Fai-agents\u002Ftools",{"title":767,"_path":768,"children":769},"Administration","\u002Fdocs\u002Fadministration",[770,773,776],{"title":771,"_path":772},"People and roles","\u002Fdocs\u002Fadministration\u002Fpeople-and-roles",{"title":774,"_path":775},"Sign-in and SSO","\u002Fdocs\u002Fadministration\u002Fsign-in-and-sso",{"title":777,"_path":778},"Security","\u002Fdocs\u002Fadministration\u002Fsecurity",[780,781],{"_path":743,"title":742},{"_path":747,"title":746},1792546943117]