{"id":2526,"date":"2025-04-30T08:15:09","date_gmt":"2025-04-30T06:15:09","guid":{"rendered":"https:\/\/1.sti-consulting.de\/from-questions-to-queries-how-ai-agents-let-you-talk-to-your-data\/"},"modified":"2025-06-06T07:05:51","modified_gmt":"2025-06-06T05:05:51","slug":"from-questions-to-queries-how-ai-agents-let-you-talk-to-your-data","status":"publish","type":"post","link":"https:\/\/sti-consulting.com\/en\/from-questions-to-queries-how-ai-agents-let-you-talk-to-your-data\/","title":{"rendered":"From Questions to Queries: How AI Agents Let You Talk to Your Data"},"content":{"rendered":"<section class=\"l-section wpb_row height_medium\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row via_grid cols_1 laptops-cols_inherit tablets-cols_inherit mobiles-cols_1 valign_top type_default stacking_default\"><div class=\"wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><p><em>From user intent to SQL-powered insights &#8211; here\u2019s how you can bring AI into your business intelligence workflow.<\/em><\/p>\n<\/div><\/div><div class=\"w-separator size_small\"><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><h2><span>Meet Your New Sidekick: The AI Agent<\/span><\/h2>\n<p>Imagine asking your company\u2019s database a question in plain English, and getting a real answer back in seconds. No SQL, no dashboards, no back-and-forth emails. Just insights.\u00a0That\u2019s the promise of AI agents, and it&#8217;s already within reach. In this article, I\u2019ll show you how to build one using Azure, structured data, and a bit of prompt engineering magic.<\/p>\n<p>We\u2019ll use a fictional retail dataset to demonstrate how an AI agent can:<\/p>\n<ul>\n<li>Understand natural language questions<\/li>\n<li>Convert them into SQL<\/li>\n<li>Return insights, fast<\/li>\n<\/ul>\n<\/div><\/div><div class=\"w-separator size_small\"><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><h2><span>What Exactly Is an AI Agent?<\/span><\/h2>\n<p><strong>AI agents<\/strong> are intelligent systems that interpret user input, process tasks autonomously or semi-autonomously, and respond with helpful output. In our context, the task is converting natural language into structured database queries.<\/p>\n<p><strong>You\u2019ve Already Met One<\/strong><\/p>\n<ul>\n<li>Chatbots on websites<\/li>\n<li>Voice assistants like Siri or Alexa<\/li>\n<li>Email spam filters<\/li>\n<li>Microsoft Copilot or Power BI Q&amp;A<\/li>\n<\/ul>\n<p><strong>Why They Matter for Data Work<\/strong><\/p>\n<p>They break down the barrier between non-technical users and the data they rely; saving time, reducing dependency on analysts, and unlocking hidden value.<\/p>\n<p><strong>Sample Use Cases<\/strong><\/p>\n<p>Let us consider a retail company and what kind of questions they may have about their customers, products and employees. These are the kinds of natural-language queries an AI agent can handle:<\/p>\n<ul>\n<li>\u201cWhich customers are likely to churn next month?\u201d<\/li>\n<li>\u201cTop 10 selling products in Q2?\u201d<\/li>\n<li>\u201cEmployees overdue for compliance training?\u201d<\/li>\n<li>\u201cDo millennial customers prefer eco-friendly products?\u201d<\/li>\n<\/ul>\n<p>We\u2019ll walk through that last one in this article using a sample dataset.<\/p>\n<\/div><\/div><div class=\"w-separator size_small\"><\/div><\/div><\/div><\/div><\/div><\/section><section class=\"l-section wpb_row height_medium\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row via_grid cols_1 laptops-cols_inherit tablets-cols_inherit mobiles-cols_1 valign_top type_default stacking_default\"><div class=\"wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><h2><span>Our Sample Dataset: Retail Customer Data<\/span><\/h2>\n<p>To demonstrate the full flow, we&#8217;ve created a fictional yet realistic dataset representing a retail loyalty system:<\/p>\n<\/div><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><table>\n<tbody>\n<tr>\n<td><strong>CustomerID<\/strong><\/td>\n<td><strong>AgeGroup<\/strong><\/td>\n<td><strong>Gender<\/strong><\/td>\n<td><strong>LoyaltyStatus<\/strong><\/td>\n<td><strong>EcoFriendlyPurchases<\/strong><\/td>\n<td><strong>LastPurchaseDate<\/strong><\/td>\n<td><strong>LoyaltyPoints<\/strong><\/td>\n<\/tr>\n<tr>\n<td>1001<\/td>\n<td>25-34<\/td>\n<td>Weiblich<\/td>\n<td>Gold<\/td>\n<td>5<\/td>\n<td>2024-05-20<\/td>\n<td>800<\/td>\n<\/tr>\n<tr>\n<td>1002<\/td>\n<td>35-44<\/td>\n<td>Male<\/td>\n<td>Silber<\/td>\n<td>2<\/td>\n<td>2024-04-18<\/td>\n<td>300<\/td>\n<\/tr>\n<tr>\n<td>1003<\/td>\n<td>18-24<\/td>\n<td>Weiblich<\/td>\n<td>Bronze<\/td>\n<td>1<\/td>\n<td>2024-03-10<\/td>\n<td>150<\/td>\n<\/tr>\n<tr>\n<td>1004<\/td>\n<td>45-54<\/td>\n<td>Male<\/td>\n<td>None<\/td>\n<td>0<\/td>\n<td>2024-01-05<\/td>\n<td>100<\/td>\n<\/tr>\n<tr>\n<td>1005<\/td>\n<td>55+<\/td>\n<td>Divers<\/td>\n<td>Gold<\/td>\n<td>4<\/td>\n<td>2024-04-01<\/td>\n<td>950<\/td>\n<\/tr>\n<tr>\n<td>1006<\/td>\n<td>25-34<\/td>\n<td>Weiblich<\/td>\n<td>Silber<\/td>\n<td>3<\/td>\n<td>2024-03-27<\/td>\n<td>600<\/td>\n<\/tr>\n<tr>\n<td>1007<\/td>\n<td>35-44<\/td>\n<td>Male<\/td>\n<td>None<\/td>\n<td>0<\/td>\n<td>2024-02-20<\/td>\n<td>75<\/td>\n<\/tr>\n<tr>\n<td>1008<\/td>\n<td>18-24<\/td>\n<td>Weiblich<\/td>\n<td>Bronze<\/td>\n<td>2<\/td>\n<td>2024-06-01<\/td>\n<td>120<\/td>\n<\/tr>\n<tr>\n<td>1009<\/td>\n<td>25-34<\/td>\n<td>Male<\/td>\n<td>Gold<\/td>\n<td>6<\/td>\n<td>2024-05-15<\/td>\n<td>700<\/td>\n<\/tr>\n<tr>\n<td>1010<\/td>\n<td>35-44<\/td>\n<td>Weiblich<\/td>\n<td>Silber<\/td>\n<td>5<\/td>\n<td>2024-04-30<\/td>\n<td>450<\/td>\n<\/tr>\n<tr>\n<td>\u2026<\/td>\n<td>\u2026<\/td>\n<td>\u2026<\/td>\n<td>\u2026<\/td>\n<td>\u2026<\/td>\n<td>\u2026<\/td>\n<td>\u2026<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div><\/div><div class=\"w-separator size_small\"><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><p>Metadata:<\/p>\n<table>\n<tbody>\n<tr>\n<td>Column Name<\/td>\n<td>Data Type<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>CustomerID<\/td>\n<td>Integer<\/td>\n<td>Unique identifier for the customer<\/td>\n<\/tr>\n<tr>\n<td>AgeGroup<\/td>\n<td>Category<\/td>\n<td>Age bucket the customer falls into<\/td>\n<\/tr>\n<tr>\n<td>Gender<\/td>\n<td>Category<\/td>\n<td>Gender of the customer<\/td>\n<\/tr>\n<tr>\n<td>LoyaltyStatus<\/td>\n<td>Category<\/td>\n<td>Tier in the loyalty program<\/td>\n<\/tr>\n<tr>\n<td>EcoFriendlyPurchases<\/td>\n<td>Integer<\/td>\n<td>Count of eco-friendly product purchases<\/td>\n<\/tr>\n<tr>\n<td>LastPurchaseDate<\/td>\n<td>Date<\/td>\n<td>Date of most recent purchase<\/td>\n<\/tr>\n<tr>\n<td>LoyaltyPoints<\/td>\n<td>Integer<\/td>\n<td>Points earned through purchases<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div><\/div><\/div><\/div><\/div><\/div><\/section><section class=\"l-section wpb_row height_medium\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row via_grid cols_1 laptops-cols_inherit tablets-cols_inherit mobiles-cols_1 valign_top type_default stacking_default\"><div class=\"wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><h2><span>Use Case: \u201cF<\/span>ind customers aged 25\u201344 who have not purchased anything within the last 90 days<span>\u201d<\/span><\/h2>\n<p>Let\u2019s take a deeper look at how the AI agent handles this question from start to finish.<\/p>\n<h3>Step 1: Understanding the User Intent<\/h3>\n<p>The user provides a natural language prompt like:<\/p>\n<p>\u201c<em>Find our most loyal customers aged 25\u201344 who have not purchased anything within the last 90 days.<\/em>\u201d<\/p>\n<p>The AI agent receives this input and needs to:<\/p>\n<ul>\n<li>Target Age Group\n<ul>\n<li>Filter customers where AgeGroup is &#8217;25-34&#8242; or &#8217;35-44&#8242;.<\/li>\n<\/ul>\n<\/li>\n<li>Define Most Loyal Customers<\/li>\n<\/ul>\n<p>Most loyal could mean:<\/p>\n<ul>\n<li>Highest LoyaltyStatus (e.g. &#8216;Gold&#8217;)<\/li>\n<li>Or highest LoyaltyPoints<br \/>\nFor this example, we&#8217;ll use LoyaltyStatus = &#8216;Gold&#8217;.<\/li>\n<\/ul>\n<ul>\n<li>Exclude Recent Purchases\n<ul>\n<li>Remove any customers who made purchases in the past 90 days.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>This is not just a keyword match\u2014it involves real understanding of the query\u2019s purpose.<\/p>\n<h3>Step 2: Passing It to the LLM with Context<\/h3>\n<p>The natural language question is passed to the Large Language Model (e.g. via Azure OpenAI), along with a prompt template that includes the schema and context:<\/p>\n<p>You are an assistant that generates SQL queries based on user input. Generate a SQL query to answer the following request:<\/p>\n<p>&#8220;<em>Find our most loyal customers aged 25\u201344 who have not purchased anything within the last 90 days<\/em>.&#8221;<\/p>\n<p>The inclusion of the schema ensures the LLM knows what data it can work with, much like giving it the blueprint of the database.<\/p>\n<h3>Step 3: LLM Generates the SQL<\/h3>\n<p>The LLM responds with a structured SQL query:<\/p>\n<p><strong>SELECT CustomerID,<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AgeGroup,<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LoyaltyStatus<\/strong><\/p>\n<p><strong>FROM retail_customers<\/strong><\/p>\n<p><strong>WHERE AgeGroup IN (&#8217;25-34&#8242;, &#8217;35-44&#8242;)<\/strong><\/p>\n<p><strong>\u00a0 AND LoyaltyStatus = &#8216;Gold&#8217;<\/strong><\/p>\n<p><strong>\u00a0 AND LastPurchaseDate &gt;= DATEADD(day, -90, GETDATE()); <\/strong><\/p>\n<p>This query:<\/p>\n<ul>\n<li>Extracts elects the customer with their age group and loyalty status<\/li>\n<li>Filters for customers between a certain age range<\/li>\n<li>Filters for customers or a particular loyalty status<\/li>\n<li>Filters for customers who have not purchased any items within the last 90 days<\/li>\n<\/ul>\n<h3>Step 4: Query Execution<\/h3>\n<p>This SQL query is passed to the Azure SQL database (or Synapse, depending on your setup) using an API bridge like Azure Functions. The query runs and fetches the aggregated data.<\/p>\n<h3>Step 5: Returning the Result<\/h3>\n<p>The result set is then displayed to the user\u2014either in a visual dashboard, conversational interface, or downloadable format. This way, the user receives meaningful insights without writing a single line of SQL.<\/p>\n<\/div><\/div><\/div><\/div><\/div><\/div><\/section><section class=\"l-section wpb_row height_medium\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row via_grid cols_1 laptops-cols_inherit tablets-cols_inherit mobiles-cols_1 valign_top type_default stacking_default\"><div class=\"wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><h2><span>Building the Architecture (Without Losing Your Mind)<\/span><\/h2>\n<\/div><\/div><div class=\"w-separator size_small\"><\/div><div class=\"w-image align_none\"><div class=\"w-image-h\"><img decoding=\"async\" width=\"1024\" height=\"270\" src=\"https:\/\/sti-consulting.com\/wp-content\/uploads\/2025\/04\/STI-Flowchart-Architecture-1024x270.webp\" class=\"attachment-large size-large\" alt=\"\" loading=\"lazy\" srcset=\"https:\/\/sti-consulting.com\/wp-content\/uploads\/2025\/04\/STI-Flowchart-Architecture-1024x270.webp 1024w, https:\/\/sti-consulting.com\/wp-content\/uploads\/2025\/04\/STI-Flowchart-Architecture-300x79.webp 300w, https:\/\/sti-consulting.com\/wp-content\/uploads\/2025\/04\/STI-Flowchart-Architecture.webp 1533w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/div><div class=\"w-separator size_small\"><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><h2><span>Choosing Your Database Wisely<\/span><\/h2>\n<p>Azure has many options. Here\u2019s how they stack up:<\/p>\n<\/div><\/div><div class=\"w-separator size_small\"><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><table>\n<tbody>\n<tr>\n<td><strong>Database<\/strong><\/td>\n<td><strong>Best Use Case<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>SQL Database<\/strong><\/td>\n<td>Classic relational queries &amp; joins<\/td>\n<\/tr>\n<tr>\n<td><strong>Synapse<\/strong><\/td>\n<td>Large-scale analytics &amp; warehouse queries<\/td>\n<\/tr>\n<tr>\n<td><strong>Cosmos DB<\/strong><\/td>\n<td>NoSQL use cases (not ideal for SQL joins)<\/td>\n<\/tr>\n<tr>\n<td><strong>Data Lake<\/strong><\/td>\n<td>Raw unstructured files<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><p><strong>Our choice?<\/strong> Azure SQL for relational data, simple joins, and business-readiness.<\/p>\n<h3><span>What If the Results Are Wrong?<\/span><\/h3>\n<p>This happens. Handle it like this:<\/p>\n<ul>\n<li>Show the generated SQL<\/li>\n<li>Ask: \u201cDid this answer your question?\u201d<\/li>\n<li>Let users rephrase or tweak queries<\/li>\n<li>Use feedback to retrain the prompt\/LLM combo<\/li>\n<\/ul>\n<p>Transparency builds trust\u2014and improves the agent over time.<\/p>\n<h3><strong>\u00a0<\/strong><span>Checklist to Go Live<\/span><\/h3>\n<ol>\n<li>Prep &amp; document your dataset &#x1f9f9;<\/li>\n<li>Set up your Azure database &#x1f4be;<\/li>\n<li>Deploy Azure OpenAI &#x1f50d;<\/li>\n<li>Build your API bridge with Azure Functions &#x1f527;<\/li>\n<li>Validate sample queries &#x1f9ea;<\/li>\n<li>Test the user interface &#x1f9fc;<\/li>\n<li>Monitor usage &amp; feedback &#x1f4ca;<\/li>\n<\/ol>\n<\/div><\/div><div class=\"w-separator size_small\"><\/div><div class=\"wpb_text_column\"><div class=\"wpb_wrapper\"><h2>Final Thoughts<\/h2>\n<p>Building an AI agent isn\u2019t about replacing analysts. It\u2019s about giving everyone access to insight\u2014instantly. If you want to make structured data usable by everyone in your business, this is your starting point.<\/p>\n<p><strong>&#x1f680;<\/strong><strong> Need support along the way? Get in touch\u2014we\u2019d love to help you build your own AI-powered solution.<\/strong><\/p>\n<\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"From user intent to SQL-powered insights &#8211; here\u2019s how you can bring AI into your business intelligence workflow. Meet Your New Sidekick: The AI Agent Imagine asking your company\u2019s database a question in plain English, and getting a real answer back in seconds. No SQL, no dashboards, no back-and-forth emails. Just insights.\u00a0That\u2019s the promise of...","protected":false},"author":26,"featured_media":2519,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[46,47],"tags":[],"bilbliothek":[],"class_list":["post-2526","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-business-intelligence-en","category-data-science-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/posts\/2526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/comments?post=2526"}],"version-history":[{"count":0,"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/posts\/2526\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/media\/2519"}],"wp:attachment":[{"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/media?parent=2526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/categories?post=2526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/tags?post=2526"},{"taxonomy":"bilbliothek","embeddable":true,"href":"https:\/\/sti-consulting.com\/en\/wp-json\/wp\/v2\/bilbliothek?post=2526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}