Blog

Guides & Tutorials

Step-by-step articles on MCP servers, AI + database integrations, and more.

Why Your AI's Order Count Includes Customers Who Never Ordered

Asked how many orders there were and got 270. There are 250 orders. The other 20 are customers with no orders. COUNT(*) counts the empty side of a LEFT JOIN as a row.

November 14, 2026

Why Your AI's Tax Total Doesn't Match the Invoices

Asked for sales tax and got $165.83. The invoices say $166.00. Each line's tax was rounded to the cent and then added. Rounding the grand total instead is a different number, and both queries succeed.

November 14, 2026

Why Your AI's SUM(DISTINCT) Dropped Real Orders

Asked for revenue and got a number that is short by $49. Two different orders were both $49. SUM(DISTINCT amount) keeps each price once, so the second order vanishes.

November 14, 2026

Why Your AI's Date Filter Drops October

Asked for orders since February and October, November and December vanished. The column is text. '2026-10-01' is less than '2026-2-01' because the character '1' comes before '2'.

November 14, 2026

Why Your AI's Combined Revenue Includes the Refunds

Asked for shop revenue plus app revenue and got $10,900. The app query lists refunds first. UNION ALL stacks by position, so the app's refunds landed in the revenue column. No error, both columns are numbers.

November 14, 2026

Why Your AI's Revenue Is 100 Times Too Big

Asked for revenue and got $8.4 million. The column holds cents, the way Stripe stores 1999 for $19.99. SUM added the cents and the AI read the result as dollars.

November 7, 2026

Why Your AI's Total Is Right on Every Row, and Wrong When You Add Them

The AI listed 500 orders and a revenue column of $10,000 on every row. That $10,000 is already the total. Adding the column makes $5 million. The query never touched an order twice.

November 7, 2026

Why Your AI's Week Starts on Monday

Asked for this week's revenue on a Saturday and got a number that is short by Sunday. Postgres DATE_TRUNC('week') starts on Monday. A US week starts on Sunday, so Sunday's orders landed in last week.

November 7, 2026

Why Your AI's Average Conversion Rate Isn't the Overall Rate

Asked for the average conversion rate and got 25.5%. One day converted half its visits and a huge day converted almost none. Averaging the daily rates treats both days as equal, so the small day dominates.

November 4, 2026

Why Your AI's Top Customer Is Two People

Asked for the top customer and got Alex Kim at $5,100. There are two Alex Kims. GROUP BY customer_name adds their orders into one row, and the real top customer is someone else.

November 4, 2026