Use CasesAISQLdashboards

Inventory Analytics Without SQL: How to Track Stock, Orders, and Fulfillment from Your Database

Running a business that handles physical goods means your database is constantly logging inventory movements, order statuses, fulfillment rates, and supplier...

James Okonkwo· Developer AdvocateApril 5, 20267 min read

Running a business that handles physical goods means your database is constantly logging inventory movements, order statuses, fulfillment rates, and supplier performance. The problem isn't that the data doesn't existit's buried in your database, and extracting it requires either a data analyst or the patience to learn SQL.

This article walks through how operations teams can get live inventory insights directly from their database, without writing a single query.

Why Your Inventory Data Lives in the Database, Not in Your Dashboard

Most inventory management systemswhether you built a custom one, use Shopify, or run an ERPwrite every transaction to a relational database. When a purchase order is created, a row is inserted. When stock is received, a count is updated. When an order ships, a fulfillment record is written.

The problem is that these databases weren't designed to be queried by non-technical users. Business intelligence tools like Tableau or Looker can connect to them, but they require data analysts to pre-build every report. If you want a new metricsay, average time from PO to receipt by supplieryou either request it from engineering or figure out the SQL yourself.

-- The query a data analyst would write for you
SELECT
  supplier_name,
  AVG(EXTRACT(EPOCH FROM (received_at - ordered_at))/86400) AS avg_days_to_receipt,
  COUNT(*) AS total_orders
FROM purchase_orders po
JOIN suppliers s ON s.id = po.supplier_id
WHERE ordered_at > NOW() - INTERVAL '90 days'
GROUP BY supplier_name
ORDER BY avg_days_to_receipt;

If you're not familiar with SQL window functions or EPOCH arithmetic, you're stuck. That's where AI-powered database interfaces change the equation.

The Key Inventory Metrics That Live in Your Database

Before looking at how to query your inventory data, it helps to understand what's actually there. Most inventory databases contain:

Stock levels table current quantities by SKU, warehouse, or bin location

Purchase orders ordered quantities, expected receipt dates, actual receipt dates, supplier IDs

Sales orders quantities sold, order dates, customer IDs, fulfillment status

Inventory movements adjustments, transfers between locations, waste and spoilage records

Supplier table supplier details, lead times, payment terms

From these tables, you can derive nearly every metric an operations manager needs: days on hand, inventory turnover, order fulfillment rate, stockout frequency, and backorder rate.

How to Ask Your Database Inventory Questions in Plain English

Tools like AI for Database let you connect your database and ask questions the way you'd ask a colleague. Instead of writing SQL, you type something like:

  • "Which SKUs have less than 7 days of stock remaining based on the last 30 days of sales?"
  • "What's our order fulfillment rate by warehouse this month?"
  • "Show me the top 10 slowest-moving products by inventory turnover"
  • "Which suppliers have the worst on-time delivery rate in the last 90 days?"
  • The AI translates each question to SQL, runs it against your database, and returns the result as a table or chart. You can ask follow-up questions"Now filter that to just the SKUs we restock from Supplier X"and the context carries forward.

    Here's the SQL that a question like "Which SKUs have less than 7 days of stock remaining?" would generate internally:

    SELECT
      s.sku,
      s.product_name,
      s.current_stock,
      ROUND(SUM(sol.quantity) / 30.0, 2) AS avg_daily_sales,
      ROUND(s.current_stock / NULLIF(SUM(sol.quantity) / 30.0, 0), 1) AS days_on_hand
    FROM stock_levels s
    LEFT JOIN sales_order_lines sol
      ON sol.sku = s.sku
      AND sol.created_at > NOW() - INTERVAL '30 days'
    GROUP BY s.sku, s.product_name, s.current_stock
    HAVING ROUND(s.current_stock / NULLIF(SUM(sol.quantity) / 30.0, 0), 1) < 7
    ORDER BY days_on_hand ASC;

    You don't need to know any of that to get the answer.

    Building a Self-Refreshing Inventory Dashboard

    One-off queries are useful. But what operations managers really need is a dashboard that stays current without manual intervention.

    AI for Database lets you build dashboards from plain-English queries and set them to refresh automatically. You might build a dashboard with four panels:

  • Low stock alerts "SKUs with less than 7 days of stock remaining, updated every 4 hours"
  • Incoming purchase orders "Purchase orders due to arrive this week, grouped by supplier"
  • Today's fulfillment rate "Percentage of orders shipped same day vs. next day"
  • Top 20 movers "Best-selling SKUs by units shipped in the last 7 days"
  • Each panel refreshes on its own schedule. When your ops team opens the dashboard in the morning, the data is already current.

    Compare this to the typical alternative: someone exports data from the WMS, pastes it into a spreadsheet, does some VLOOKUP work, and emails a PDF at 9am. The PDF is already out of date by the time it lands in inboxes.

    Setting Up Automated Inventory Alerts

    Beyond dashboards, you can set up action workflows that monitor your database and fire alerts when conditions are met.

    Practical examples for inventory:

  • Stockout warning: When days_on_hand drops below 5 for any SKU in the top 100 by revenue, send a Slack message to #ops-alerts with the SKU name and current stock level
  • PO overdue: When a purchase order's expected receipt date has passed and it hasn't been marked received, email the buyer with the PO number and supplier name
  • Fulfillment rate drop: When same-day fulfillment rate falls below 90% on any given day, notify the operations manager automatically
  • These workflows don't require stored procedures, database triggers, or a DBA. You define the condition in plain English, specify the action (Slack, email, or webhook), and the system watches your database continuously.

    The underlying monitoring logic runs a query like this at set intervals:

    SELECT sku, product_name, current_stock, days_on_hand
    FROM inventory_summary_view
    WHERE days_on_hand < 5
      AND sku IN (
        SELECT sku FROM revenue_by_sku
        ORDER BY revenue_last_30d DESC
        LIMIT 100
      );

    But you never write that yourself. You describe the condition, and the system handles the rest.

    Connecting Common Inventory Databases

    AI for Database connects to the databases that inventory systems actually use:

  • PostgreSQL or MySQL most custom-built inventory systems and ERPs
  • Supabase popular with newer direct-to-consumer brands building custom tools
  • MongoDB used by some warehouse management systems for schema flexibility
  • MS SQL Server common in enterprise ERPs like Microsoft Dynamics
  • If your system writes data to a supported database, you can connect and query it. You don't need the vendor to build a reporting APIyou're going directly to the source.

    Ready to try AI for Database?

    Query your database in plain English. No SQL required. Start free today.