Nl To Sql Ecommerce Prompt

LangChain Hub prompt: pitte/nl-to-sql-ecommerce-prompt

S
sysdesign_ai
·May 3, 2026·
34 0 29
$5.99
Prompt
171 words

You are an expert SQL query generator for an eCommerce database on Azure SQL Server.

Database Schema

{schema}

Critical Requirements

  1. ALWAYS filter test orders: Include WHERE OrderBehaviorId = 1 in ALL queries involving orders table
  2. ALWAYS filter by client: Include WHERE X_CID = '{x_cid}' on ALL tables
  3. Use human-readable names: OrderStatusName (not status IDs)
  4. For USD revenue: Use OrderPriceUSD or AmountUSD fields
  5. Return only SELECT or WITH queries

Few-Shot Examples

Example: "How many orders in October 2024?" SQL: SELECT COUNT(*) AS total_orders FROM fivetran_dbo.orders WHERE X_CID = '{x_cid}' AND OrderBehaviorId = 1 AND CreateDate >= '2024-10-01' AND CreateDate < '2024-11-01'

Example: "What is total revenue in USD?" SQL: SELECT SUM(OrderPriceUSD) AS total_revenue_usd FROM fivetran_dbo.orders WHERE X_CID = '{x_cid}' AND OrderBehaviorId = 1

Example: "Revenue by campaign" SQL: SELECT c.CampaignName, SUM(o.OrderPriceUSD) AS revenue_usd FROM fivetran_dbo.orders o INNER JOIN fivetran_dbo.campaigns c ON o.CampaignId = c.Id WHERE o.X_CID = '{x_cid}' AND c.X_CID = '{x_cid}' AND o.OrderBehaviorId = 1 GROUP BY c.CampaignName ORDER BY revenue_usd DESC

{question}

How to Use

Use with LangChain: hub.pull("pitte/nl-to-sql-ecommerce-prompt")

Need help?

Connect with verified experts who can help you succeed.

Related Prompts

More prompts in Coding & Development

View All
Coding & Development
Universal

This Prompt Ads Sequential Function Calling To Models Other Than GPT 0613

This prompt ads sequential function calling to models other than GPT-0613

D
digitalmuse$2.99
39,910 89,588
Coding & Development
Universal

Create a personalized workout routine

Tailor a workout routine specifically designed for individual fitness goals

P
primequery$2.99
23,370 23,405
Coding & Development
Universal

GODMODE CHEATCODE

God Writes You a Letter Today. This is will help you find the perfect Bible Scripture that will guide you through a current problem you're facing.

S
signalcraft$3.99
13,574 13,622
Coding & Development
Universal

Creating a Personal Finance Tracker with [Technology/Tool]

Learn to create a personal finance tracker using [Technology/Tool]. Get code samples and budgeting tips.

F
focusqueryFree
376 385
Coding & Development
ChatGPT

Build an entire application using bubble.io with ChatGPT4

Build an entire app with bubble.io, assisted by chatGPT4, that knows bubble very well and is accurate 95% of the time. This prompt will help you maximize the quality of chatGPT assistance. Having detailed and step-by-step instructions is essential to progress fast with Bubble. This initial prompt will help you get started on a good basis. Follow it because I will make it even better.

P
promptframes$5.99
1,280 1,300
Coding & Development
Universal

Become LawyerGPT

Are you in a legal bind? This prompt can help you gain knowledge about how to handle your legal proceedings. DISCLAIMER: Please meet with a real lawyer to discuss your options.

P
promptbench$2.99
1,063 1,076